FuncCandidateList clist,
ptr;
Oid funcid = InvalidOid;
- List *names = makeList1(makeString(fname));
+ List *names = list_make1(makeString(fname));
ptr = clist = FuncnameGetCandidates(names, 1);
- freeList(names);
+ list_free(names);
if (!ptr)
return funcid;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/common/tupdesc.c,v 1.103 2004/05/26 04:41:03 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/access/common/tupdesc.c,v 1.104 2004/05/30 23:40:25 neilc Exp $
*
* NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be
/*
* allocate a new tuple descriptor
*/
- natts = length(schema);
+ natts = list_length(schema);
desc = CreateTemplateTupleDesc(natts, false);
constr->has_not_null = false;
attname = entry->colname;
atttypmod = entry->typename->typmod;
- attdim = length(entry->typename->arrayBounds);
+ attdim = list_length(entry->typename->arrayBounds);
if (entry->typename->setof)
ereport(ERROR,
int varattno;
/* does the list length match the number of attributes? */
- if (length(colaliases) != natts)
+ if (list_length(colaliases) != natts)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("number of aliases does not match number of columns")));
/* OK, use the aliases instead */
for (varattno = 0; varattno < natts; varattno++)
{
- char *label = strVal(nth(varattno, colaliases));
+ char *label = strVal(list_nth(colaliases, varattno));
if (label != NULL)
namestrcpy(&(tupdesc->attrs[varattno]->attname), label);
errmsg("no column alias was provided")));
/* the alias list length must be 1 */
- if (length(colaliases) != 1)
+ if (list_length(colaliases) != 1)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("number of aliases does not match number of columns")));
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.11 2004/05/26 04:41:05 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.12 2004/05/30 23:40:25 neilc Exp $
*
*-------------------------------------------------------------------------
*/
{
if (is_root != split->is_root)
elog(LOG, "forget_matching_split: fishy is_root data");
- incomplete_splits = lremove(split, incomplete_splits);
+ incomplete_splits = list_delete_ptr(incomplete_splits, split);
break; /* need not look further */
}
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
ResultRelInfo *resultRelInfo;
ListCell *l;
- numResultRelations = length(resultRelations);
+ numResultRelations = list_length(resultRelations);
resultRelInfos = (ResultRelInfo *)
palloc(numResultRelations * sizeof(ResultRelInfo));
resultRelInfo = resultRelInfos;
foreach(l, parseTree->rowMarks)
{
- Index rti = lfirsti(l);
+ Index rti = lfirst_int(l);
Oid relid = getrelid(rti, rangeTable);
Relation relation;
execRowMark *erm;
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);
int rtsize;
MemoryContext oldcontext;
- rtsize = length(estate->es_range_table);
+ rtsize = list_length(estate->es_range_table);
epq->estate = epqstate = CreateExecutorState();
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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 */
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)
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;
*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));
ExecTargetListLength(List *targetlist)
{
/* This used to be more complex, but fjoins are dead */
- return length(targetlist);
+ return list_length(targetlist);
}
/*
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
int cur_resno = 1;
char fldname[NAMEDATALEN];
- typeInfo = CreateTemplateTupleDesc(length(exprList), false);
+ typeInfo = CreateTemplateTupleDesc(list_length(exprList), false);
foreach(l, exprList)
{
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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 */
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);
}
* Get cached list of index OIDs
*/
indexoidlist = RelationGetIndexList(resultRelation);
- len = length(indexoidlist);
+ len = list_length(indexoidlist);
if (len == 0)
return;
i = 0;
foreach(l, indexoidlist)
{
- Oid indexOid = lfirsto(l);
+ Oid indexOid = lfirst_oid(l);
Relation indexDesc;
IndexInfo *ii;
i++;
}
- freeList(indexoidlist);
+ list_free(indexoidlist);
}
/* ----------------------------------------------------------------
* 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 $
*
*-------------------------------------------------------------------------
*/
* 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)
{
/*
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
/*
* Set up empty vector of subplan states
*/
- nplans = length(node->appendplans);
+ nplans = list_length(node->appendplans);
appendplanstates = (PlanState **) palloc0(nplans * sizeof(PlanState *));
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);
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
/*
* 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++;
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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;
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
* 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);
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 :
*/
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))
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));
}
}
*/
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,
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
/*
* 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)
{
* 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 $
*
*-------------------------------------------------------------------------
*/
* 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)
{
* 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)
{
{
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;
*/
foreach(plst, subplan->paramIds)
{
- int paramid = lfirsti(plst);
+ int paramid = lfirst_int(plst);
ParamExecData *prmdata;
prmdata = &(innerecontext->ecxt_param_exec_vals[paramid]);
foreach(lst, subplan->setParam)
{
- int paramid = lfirsti(lst);
+ int paramid = lfirst_int(lst);
ParamExecData *prm = &(estate->es_param_exec_vals[paramid]);
prm->execPlan = node;
/* 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;
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);
*/
foreach(l, subplan->setParam)
{
- int paramid = lfirsti(l);
+ int paramid = lfirst_int(l);
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
prm->execPlan = NULL;
{
foreach(l, subplan->setParam)
{
- int paramid = lfirsti(l);
+ int paramid = lfirst_int(l);
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
prm->execPlan = NULL;
*/
foreach(l, subplan->setParam)
{
- int paramid = lfirsti(l);
+ int paramid = lfirst_int(l);
ParamExecData *prm = &(estate->es_param_exec_vals[paramid]);
prm->execPlan = node;
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
ListCell *l;
tidList = (ItemPointerData *)
- palloc(length(tidstate->tss_tideval) * sizeof(ItemPointerData));
+ palloc(list_length(tidstate->tss_tideval) * sizeof(ItemPointerData));
foreach(l, evalList)
{
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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")));
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);
}
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));
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.124 2004/05/26 18:35:33 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.125 2004/05/30 23:40:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
-#define DISABLE_LIST_COMPAT
-
#include <errno.h>
#include <pwd.h>
#include <fcntl.h>
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.283 2004/05/26 13:56:47 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.284 2004/05/30 23:40:27 neilc Exp $
*
*-------------------------------------------------------------------------
*/
-#define DISABLE_LIST_COMPAT
-
#include "postgres.h"
#include "nodes/parsenodes.h"
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.222 2004/05/26 13:56:47 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.223 2004/05/30 23:40:27 neilc Exp $
*
*-------------------------------------------------------------------------
*/
-#define DISABLE_LIST_COMPAT
-
#include "postgres.h"
#include "nodes/params.h"
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/list.c,v 1.57 2004/05/26 04:41:19 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/list.c,v 1.58 2004/05/30 23:40:27 neilc Exp $
*
*-------------------------------------------------------------------------
*/
-#define DISABLE_LIST_COMPAT
-
#include "postgres.h"
#include "nodes/pg_list.h"
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.43 2004/05/10 22:44:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.44 2004/05/30 23:40:27 neilc Exp $
*
*-------------------------------------------------------------------------
*/
A_Expr *a = makeNode(A_Expr);
a->kind = kind;
- a->name = makeList1(makeString((char *) name));
+ a->name = list_make1(makeString((char *) name));
a->lexpr = lexpr;
a->rexpr = rexpr;
return a;
{
TypeName *n = makeNode(TypeName);
- n->names = makeList1(makeString(typnam));
+ n->names = list_make1(makeString(typnam));
n->typmod = -1;
return n;
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.237 2004/05/26 04:41:19 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.238 2004/05/30 23:40:27 neilc Exp $
*
* NOTES
* Every node type that can appear in stored rules' parsetrees *must*
*
*-------------------------------------------------------------------------
*/
-#define DISABLE_LIST_COMPAT
-
#include "postgres.h"
#include <ctype.h>
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.67 2004/05/26 04:41:19 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.68 2004/05/30 23:40:27 neilc Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
RangeTblEntry *rte;
Assert(var->varno > 0 &&
- (int) var->varno <= length(rtable));
+ (int) var->varno <= list_length(rtable));
rte = rt_fetch(var->varno, rtable);
relname = rte->eref->aliasname;
attname = get_rte_attribute_name(rte, var->varattno);
char *opname;
opname = get_opname(e->opno);
- if (length(e->args) > 1)
+ if (list_length(e->args) > 1)
{
print_expr(get_leftop((Expr *) e), rtable);
printf(" %s ", ((opname != NULL) ? opname : "(invalid operator)"));
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/read.c,v 1.42 2004/05/26 04:41:19 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/read.c,v 1.43 2004/05/30 23:40:27 neilc Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
if (endptr != token + tok_len)
elog(ERROR, "unrecognized integer: \"%.*s\"",
tok_len, token);
- l = lappendi(l, val);
+ l = lappend_int(l, val);
}
}
else if (tok_len == 1 && token[0] == 'o')
if (endptr != token + tok_len)
elog(ERROR, "unrecognized OID: \"%.*s\"",
tok_len, token);
- l = lappendo(l, val);
+ l = lappend_oid(l, val);
}
}
else
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.170 2004/05/26 04:41:19 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.171 2004/05/30 23:40:27 neilc Exp $
*
* NOTES
* Path and Plan nodes do not have any readfuncs support, because we
*
*-------------------------------------------------------------------------
*/
-#define DISABLE_LIST_COMPAT
-
#include "postgres.h"
#include <math.h>
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_eval.c,v 1.68 2004/05/26 04:41:20 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_eval.c,v 1.69 2004/05/30 23:40:27 neilc Exp $
*
*-------------------------------------------------------------------------
*/
/* Get the next input relation and push it */
cur_rel_index = (int) tour[rel_count];
- stack[stack_depth] = (RelOptInfo *) nth(cur_rel_index - 1,
- evaldata->initial_rels);
+ stack[stack_depth] = (RelOptInfo *) list_nth(evaldata->initial_rels,
+ cur_rel_index - 1);
stack_depth++;
/*
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.115 2004/05/26 04:41:21 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.116 2004/05/30 23:40:28 neilc Exp $
*
*-------------------------------------------------------------------------
*/
/*
* The result should join all the query's base rels.
*/
- Assert(bms_num_members(rel->relids) == length(root->base_rel_list));
+ Assert(bms_num_members(rel->relids) == list_length(root->base_rel_list));
return rel;
}
* XXX for now, can't handle inherited expansion of FOR UPDATE; can we
* do better?
*/
- if (intMember(parentRTindex, root->rowMarks))
+ if (list_member_int(root->rowMarks, parentRTindex))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("SELECT FOR UPDATE is not supported for inheritance queries")));
*/
foreach(il, inheritlist)
{
- int childRTindex = lfirsti(il);
+ int childRTindex = lfirst_int(il);
RangeTblEntry *childrte;
Oid childOID;
RelOptInfo *childrel;
/* We need a workspace for keeping track of set-op type coercions */
differentTypes = (bool *)
- palloc0((length(subquery->targetList) + 1) * sizeof(bool));
+ palloc0((list_length(subquery->targetList) + 1) * sizeof(bool));
/*
* If there are any restriction clauses that have been attached to the
* dynamic-programming algorithm we must employ to consider all ways
* of joining the child nodes.
*/
- levels_needed = length(from->fromlist);
+ levels_needed = list_length(from->fromlist);
if (levels_needed <= 0)
return NULL; /* nothing to do? */
*/
if (joinitems[levels_needed] == NIL)
elog(ERROR, "failed to build any %d-way joins", levels_needed);
- Assert(length(joinitems[levels_needed]) == 1);
+ Assert(list_length(joinitems[levels_needed]) == 1);
rel = (RelOptInfo *) linitial(joinitems[levels_needed]);
}
}
- freeList(vars);
+ list_free(vars);
bms_free(tested);
return safe;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.66 2004/05/26 04:41:21 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.67 2004/05/30 23:40:28 neilc Exp $
*
*-------------------------------------------------------------------------
*/
* behave in the simple way we are expecting.) Most of the tests
* here can be done more efficiently with rinfo than without.
*/
- if (is_opclause(clause) && length(((OpExpr *) clause)->args) == 2)
+ if (is_opclause(clause) && list_length(((OpExpr *) clause)->args) == 2)
{
OpExpr *expr = (OpExpr *) clause;
bool varonleft = true;
*/
s1 = restriction_selectivity(root,
BooleanEqualOperator,
- makeList2(var,
- makeBoolConst(true,
+ list_make2(var,
+ makeBoolConst(true,
false)),
varRelid);
}
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.127 2004/05/26 04:41:21 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.128 2004/05/30 23:40:28 neilc Exp $
*
*-------------------------------------------------------------------------
*/
Cost startup_cost = 0;
Cost run_cost = 0;
Cost cpu_per_tuple;
- int ntuples = length(tideval);
+ int ntuples = list_length(tideval);
/* Should only be applied to base relations */
Assert(baserel->relid > 0);
outer_path->parent->width);
double innerbytes = relation_byte_size(inner_path_rows,
inner_path->parent->width);
- int num_hashclauses = length(hashclauses);
+ int num_hashclauses = list_length(hashclauses);
int virtualbuckets;
int physicalbuckets;
int numbatches;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.159 2004/05/26 04:41:21 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.160 2004/05/30 23:40:28 neilc Exp $
*
*-------------------------------------------------------------------------
*/
Expr *nonnullarg = ((NullTest *) predicate)->arg;
if (is_opclause(clause) &&
- member(nonnullarg, ((OpExpr *) clause)->args) &&
+ list_member(((OpExpr *) clause)->args, nonnullarg) &&
op_strict(((OpExpr *) clause)->opno))
return true;
if (is_funcclause(clause) &&
- member(nonnullarg, ((FuncExpr *) clause)->args) &&
+ list_member(((FuncExpr *) clause)->args, nonnullarg) &&
func_strict(((FuncExpr *) clause)->funcid))
return true;
return false; /* we can't succeed below... */
* Note that we are making a pathnode for a single-scan indexscan;
* therefore, indexinfo etc should be single-element lists.
*/
- pathnode->indexinfo = makeList1(index);
- pathnode->indexclauses = makeList1(allclauses);
- pathnode->indexquals = makeList1(indexquals);
+ pathnode->indexinfo = list_make1(index);
+ pathnode->indexclauses = list_make1(allclauses);
+ pathnode->indexquals = list_make1(indexquals);
pathnode->isjoininner = true;
* Always assume the join type is JOIN_INNER; even if some of the join
* clauses come from other contexts, that's not our problem.
*/
- allclauses = set_ptrUnion(rel->baserestrictinfo, allclauses);
+ allclauses = list_union_ptr(rel->baserestrictinfo, allclauses);
pathnode->rows = rel->tuples *
clauselist_selectivity(root,
allclauses,
foreach(l, clausegroups)
{
- allclauses = nconc(allclauses, listCopy((List *) lfirst(l)));
+ allclauses = list_concat(allclauses, list_copy((List *) lfirst(l)));
}
return allclauses;
}
orclauses = lappend(orclauses, make_ands_explicit(andlist));
}
- if (length(orclauses) > 1)
+ if (list_length(orclauses) > 1)
return make_orclause(orclauses);
else
return (Expr *) linitial(orclauses);
break;
default:
- result = makeList1(rinfo);
+ result = list_make1(rinfo);
break;
}
elog(ERROR, "no = operator for opclass %u", opclass);
expr = make_opclause(oproid, BOOLOID, false,
(Expr *) leftop, (Expr *) prefix_const);
- result = makeList1(make_restrictinfo(expr, true, true));
+ result = list_make1(make_restrictinfo(expr, true, true));
return result;
}
elog(ERROR, "no >= operator for opclass %u", opclass);
expr = make_opclause(oproid, BOOLOID, false,
(Expr *) leftop, (Expr *) prefix_const);
- result = makeList1(make_restrictinfo(expr, true, true));
+ result = list_make1(make_restrictinfo(expr, true, true));
/*-------
* If we can create a string larger than the prefix, we can say
(Expr *) leftop,
(Expr *) makeConst(datatype, -1, opr1right,
false, false));
- result = makeList1(make_restrictinfo(expr, true, true));
+ result = list_make1(make_restrictinfo(expr, true, true));
/* create clause "key <= network_scan_last( rightop )" */
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.87 2004/05/26 04:41:22 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.88 2004/05/30 23:40:28 neilc Exp $
*
*-------------------------------------------------------------------------
*/
/* Make a pathkey list with this guy first. */
if (l != list_head(all_pathkeys))
cur_pathkeys = lcons(front_pathkey,
- lremove(front_pathkey,
- listCopy(all_pathkeys)));
+ list_delete_ptr(list_copy(all_pathkeys),
+ front_pathkey));
else
cur_pathkeys = all_pathkeys; /* no work at first one... */
/* Forget it if can't use all the clauses in right/full join */
if (useallclauses &&
- length(cur_mergeclauses) != length(mergeclause_list))
+ list_length(cur_mergeclauses) != list_length(mergeclause_list))
continue;
/*
else
continue;
}
- if (useallclauses && length(mergeclauses) != length(mergeclause_list))
+ if (useallclauses && list_length(mergeclauses) != list_length(mergeclause_list))
continue;
/* Compute the required ordering of the inner path */
* consider both cheap startup cost and cheap total cost. Ignore
* inner_cheapest_total, since we already made a path with it.
*/
- num_sortkeys = length(innersortkeys);
+ num_sortkeys = list_length(innersortkeys);
if (num_sortkeys > 1 && !useallclauses)
- trialsortkeys = listCopy(innersortkeys); /* need modifiable copy */
+ trialsortkeys = list_copy(innersortkeys); /* need modifiable copy */
else
trialsortkeys = innersortkeys; /* won't really truncate */
cheapest_startup_inner = NULL;
* 'sortkeycnt' innersortkeys. NB: trialsortkeys list is
* modified destructively, which is why we made a copy...
*/
- trialsortkeys = ltruncate(sortkeycnt, trialsortkeys);
+ trialsortkeys = list_truncate(trialsortkeys, sortkeycnt);
innerpath = get_cheapest_path_for_pathkeys(innerrel->pathlist,
trialsortkeys,
TOTAL_COST);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.68 2004/05/26 04:41:22 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.69 2004/05/30 23:40:28 neilc Exp $
*
*-------------------------------------------------------------------------
*/
{
RelOptInfo *jrel = (RelOptInfo *) lfirst(nr);
- if (!ptrMember(jrel, result_rels))
+ if (!list_member_ptr(result_rels, jrel))
result_rels = lcons(jrel, result_rels);
}
}
jrel = make_join_rel(root, old_rel, new_rel,
JOIN_INNER);
/* Avoid making duplicate entries ... */
- if (jrel && !ptrMember(jrel, result_rels))
+ if (jrel && !list_member_ptr(result_rels, jrel))
result_rels = lcons(jrel, result_rels);
break; /* need not consider more
* joininfos */
{
RelOptInfo *jrel = (RelOptInfo *) lfirst(nr);
- if (!ptrMember(jrel, result_rels))
+ if (!list_member_ptr(result_rels, jrel))
result_rels = lcons(jrel, result_rels);
}
}
* Avoid entering same joinrel into our output list more
* than once.
*/
- if (jrel && !ptrMember(jrel, result))
+ if (jrel && !list_member_ptr(result, jrel))
result = lcons(jrel, result);
}
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.58 2004/05/26 04:41:22 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.59 2004/05/30 23:40:28 neilc Exp $
*
*-------------------------------------------------------------------------
*/
*/
newrinfos = make_restrictinfo_from_indexclauses(bestpath->indexclauses,
true, true);
- Assert(length(newrinfos) == 1);
+ Assert(list_length(newrinfos) == 1);
or_rinfo = (RestrictInfo *) linitial(newrinfos);
- rel->baserestrictinfo = nconc(rel->baserestrictinfo, newrinfos);
+ rel->baserestrictinfo = list_concat(rel->baserestrictinfo, newrinfos);
/*
* Adjust the original OR clause's cached selectivity to compensate
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.57 2004/05/26 04:41:22 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.58 2004/05/30 23:40:28 neilc Exp $
*
*-------------------------------------------------------------------------
*/
while (cursetlink)
{
List *curset = (List *) lfirst(cursetlink);
- bool item1here = member(item1, curset);
- bool item2here = member(item2, curset);
+ bool item1here = list_member(curset, item1);
+ bool item2here = list_member(curset, item2);
/* must advance cursetlink before lremove possibly pfree's it */
cursetlink = lnext(cursetlink);
/* Build the new set only when we know we must */
if (newset == NIL)
- newset = makeList2(item1, item2);
+ newset = list_make2(item1, item2);
/* Found a set to merge into our new set */
- newset = set_union(newset, curset);
+ newset = list_union(newset, curset);
/*
* Remove old set from equi_key_list.
*/
- root->equi_key_list = lremove(curset, root->equi_key_list);
- freeList(curset); /* might as well recycle old cons cells */
+ root->equi_key_list = list_delete_ptr(root->equi_key_list, curset);
+ list_free(curset); /* might as well recycle old cons cells */
}
}
/* Build the new set only when we know we must */
if (newset == NIL)
- newset = makeList2(item1, item2);
+ newset = list_make2(item1, item2);
root->equi_key_list = lcons(newset, root->equi_key_list);
}
foreach(cursetlink, root->equi_key_list)
{
List *curset = (List *) lfirst(cursetlink);
- int nitems = length(curset);
+ int nitems = list_length(curset);
Relids *relids;
bool have_consts;
ListCell *ptr1;
{
List *curset = (List *) lfirst(cursetlink);
- if (member(item, curset))
+ if (list_member(curset, item))
return curset;
}
- newset = makeList1(item);
+ newset = list_make1(item);
root->equi_key_list = lcons(newset, root->equi_key_list);
return newset;
}
* canonicalized the keys, so that equivalent-key knowledge is
* used when deciding if an item is redundant.
*/
- if (!ptrMember(cpathkey, new_pathkeys))
+ if (!list_member_ptr(new_pathkeys, cpathkey))
new_pathkeys = lappend(new_pathkeys, cpathkey);
}
return new_pathkeys;
{
List *curset = (List *) lfirst(cursetlink);
- if (member(item, curset))
- return length(curset) - 1;
+ if (list_member(curset, item))
+ return list_length(curset) - 1;
}
return 0;
}
* input, but query root not accessible here...
*/
#ifdef NOT_USED
- Assert(ptrMember(subkey1, root->equi_key_list));
- Assert(ptrMember(subkey2, root->equi_key_list));
+ Assert(list_member_ptr(root->equi_key_list, subkey1));
+ Assert(list_member_ptr(root->equi_key_list, subkey2));
#endif
/*
List *subkey1 = (List *) lfirst(key1);
List *subkey2 = (List *) lfirst(key2);
- Assert(length(subkey1) == 1);
- Assert(length(subkey2) == 1);
+ Assert(list_length(subkey1) == 1);
+ Assert(list_length(subkey2) == 1);
if (!equal(subkey1, subkey2))
return PATHKEYS_DIFFERENT; /* no need to keep looking */
}
* Eliminate redundant ordering info; could happen if query is
* such that index keys are equijoined...
*/
- if (!ptrMember(cpathkey, retval))
+ if (!list_member_ptr(retval, cpathkey))
retval = lappend(retval, cpathkey);
indexkeys++;
{
List *retval = NIL;
int retvallen = 0;
- int outer_query_keys = length(root->query_pathkeys);
+ int outer_query_keys = list_length(root->query_pathkeys);
List *sub_tlist = rel->subplan->targetlist;
ListCell *i;
score = count_canonical_peers(root, outer_item);
/* +1 if it matches the proper query_pathkeys item */
if (retvallen < outer_query_keys &&
- member(outer_item,
- nth(retvallen, root->query_pathkeys)))
+ list_member(list_nth(root->query_pathkeys, retvallen), outer_item))
score++;
if (score > best_score)
{
* Eliminate redundant ordering info; could happen if outer query
* equijoins subquery keys...
*/
- if (!ptrMember(cpathkey, retval))
+ if (!list_member_ptr(retval, cpathkey))
{
retval = lappend(retval, cpathkey);
retvallen++;
* canonicalize_pathkeys() might replace it with a longer sublist
* later.
*/
- pathkeys = lappend(pathkeys, makeList1(pathkey));
+ pathkeys = lappend(pathkeys, list_make1(pathkey));
}
return pathkeys;
}
*/
if ((pathkey == restrictinfo->left_pathkey ||
pathkey == restrictinfo->right_pathkey) &&
- !ptrMember(restrictinfo, mergeclauses))
+ !list_member_ptr(mergeclauses, restrictinfo))
{
matched_restrictinfos = lappend(matched_restrictinfos,
restrictinfo);
* If we did find usable mergeclause(s) for this sort-key
* position, add them to result list.
*/
- mergeclauses = nconc(mergeclauses, matched_restrictinfos);
+ mergeclauses = list_concat(mergeclauses, matched_restrictinfos);
}
return mergeclauses;
* pathkey, a simple ptrMember test is sufficient to detect
* redundant keys.
*/
- if (!ptrMember(pathkey, pathkeys))
+ if (!list_member_ptr(pathkeys, pathkey))
pathkeys = lappend(pathkeys, pathkey);
}
*
* Unlike merge pathkeys, this is an all-or-nothing affair: it does us
* no good to order by just the first key(s) of the requested ordering.
- * So the result is always either 0 or length(root->query_pathkeys).
+ * So the result is always either 0 or list_length(root->query_pathkeys).
*/
int
pathkeys_useful_for_ordering(Query *root, List *pathkeys)
if (pathkeys_contained_in(root->query_pathkeys, pathkeys))
{
/* It's useful ... or at least the first N keys are */
- return length(root->query_pathkeys);
+ return list_length(root->query_pathkeys);
}
return 0; /* path ordering not useful */
* Note: not safe to modify input list destructively, but we can avoid
* copying the list if we're not actually going to change it
*/
- if (nuseful == length(pathkeys))
+ if (nuseful == list_length(pathkeys))
return pathkeys;
else
- return ltruncate(nuseful, listCopy(pathkeys));
+ return list_truncate(list_copy(pathkeys), nuseful);
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/tidpath.c,v 1.19 2004/05/26 04:41:22 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/tidpath.c,v 1.20 2004/05/30 23:40:28 neilc Exp $
*
*-------------------------------------------------------------------------
*/
if (node->opno != TIDEqualOperator)
return rnode;
- if (length(node->args) != 2)
+ if (list_length(node->args) != 2)
return rnode;
arg1 = linitial(node->args);
arg2 = lsecond(node->args);
node = (Node *) lfirst(l);
frtn = TidqualFromExpr(varno, (Expr *) node);
if (frtn)
- rlst = nconc(rlst, frtn);
+ rlst = list_concat(rlst, frtn);
else
{
if (rlst)
- freeList(rlst);
+ list_free(rlst);
rlst = NIL;
break;
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.170 2004/05/26 04:41:24 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.171 2004/05/30 23:40:28 neilc Exp $
*
*-------------------------------------------------------------------------
*/
*/
if (get_loc_restrictinfo(best_path) != NIL)
set_qpqual((Plan) plan,
- nconc(get_qpqual((Plan) plan),
+ list_concat(get_qpqual((Plan) plan),
get_actual_clauses(get_loc_restrictinfo(best_path))));
#endif
elog(ERROR, "could not find UniquePath in in_info_list");
/* set up to record positions of unique columns */
- numGroupCols = length(uniq_exprs);
+ numGroupCols = list_length(uniq_exprs);
groupColIdx = (AttrNumber *) palloc(numGroupCols * sizeof(AttrNumber));
groupColPos = 0;
/* not sure if tlist might be shared with other nodes, so copy */
newtlist = copyObject(subplan->targetlist);
- nextresno = length(newtlist) + 1;
+ nextresno = list_length(newtlist) + 1;
newitems = false;
foreach(l, uniq_exprs)
* need to worry about the plain AND case. Also, pointer comparison
* should be enough to determine RestrictInfo matches.
*/
- Assert(length(best_path->indexclauses) == 1);
- scan_clauses = set_ptrUnion(scan_clauses,
- (List *) linitial(best_path->indexclauses));
+ Assert(list_length(best_path->indexclauses) == 1);
+ scan_clauses = list_union_ptr(scan_clauses,
+ (List *) linitial(best_path->indexclauses));
}
/* Reduce RestrictInfo list to bare expressions */
* added to qpqual. The upshot is that qpquals must contain scan_clauses
* minus whatever appears in indxquals.
*/
- if (length(indxquals) > 1)
+ if (list_length(indxquals) > 1)
{
/*
* Build an expression representation of the indexqual, expanding
* scan_clause are not great; perhaps we need more smarts here.)
*/
indxqual_or_expr = make_expr_from_indexclauses(indxquals);
- qpqual = set_difference(scan_clauses, makeList1(indxqual_or_expr));
+ qpqual = list_difference(scan_clauses, list_make1(indxqual_or_expr));
}
else
{
* behavior.
*/
Assert(stripped_indxquals != NIL);
- qpqual = set_difference(scan_clauses, linitial(stripped_indxquals));
+ qpqual = list_difference(scan_clauses, linitial(stripped_indxquals));
}
/*
List *indexclauses = innerpath->indexclauses;
if (innerpath->isjoininner &&
- length(indexclauses) == 1) /* single indexscan? */
+ list_length(indexclauses) == 1) /* single indexscan? */
{
joinrestrictclauses =
select_nonredundant_join_clauses(root,
* the list of quals that must be checked as qpquals.
*/
mergeclauses = get_actual_clauses(best_path->path_mergeclauses);
- joinclauses = set_difference(joinclauses, mergeclauses);
+ joinclauses = list_difference(joinclauses, mergeclauses);
/*
* Rearrange mergeclauses, if needed, so that the outer variable is
* the list of quals that must be checked as qpquals.
*/
hashclauses = get_actual_clauses(best_path->path_hashclauses);
- joinclauses = set_difference(joinclauses, hashclauses);
+ joinclauses = list_difference(joinclauses, hashclauses);
/*
* Rearrange hashclauses, if needed, so that the outer variable is
Assert(IsA(rinfo, RestrictInfo));
clause = (OpExpr *) rinfo->clause;
- if (!IsA(clause, OpExpr) || length(clause->args) != 2)
+ if (!IsA(clause, OpExpr) || list_length(clause->args) != 2)
elog(ERROR, "indexqual clause is not binary opclause");
/*
get_op_opclass_properties(newclause->opno, opclass,
&stratno, &stratsubtype, &recheck);
- *strategy = lappendi(*strategy, stratno);
- *subtype = lappendo(*subtype, stratsubtype);
- *lossy = lappendi(*lossy, (int) recheck);
+ *strategy = lappend_int(*strategy, stratno);
+ *subtype = lappend_oid(*subtype, stratsubtype);
+ *lossy = lappend_int(*lossy, (int) recheck);
}
}
temp->opfuncid = InvalidOid;
temp->opresulttype = clause->opresulttype;
temp->opretset = clause->opretset;
- temp->args = listCopy(clause->args);
+ temp->args = list_copy(clause->args);
/* Commute it --- note this modifies the temp node in-place. */
CommuteClause(temp);
t_list = lappend(t_list, temp);
AttrNumber *sortColIdx;
Oid *sortOperators;
- /* We will need at most length(pathkeys) sort columns; possibly less */
- numsortkeys = length(pathkeys);
+ /* We will need at most list_length(pathkeys) sort columns; possibly less */
+ numsortkeys = list_length(pathkeys);
sortColIdx = (AttrNumber *) palloc(numsortkeys * sizeof(AttrNumber));
sortOperators = (Oid *) palloc(numsortkeys * sizeof(Oid));
if (!tlist_member(lfirst(k), tlist))
break;
}
- freeList(exprvars);
+ list_free(exprvars);
if (!k)
break; /* found usable expression */
}
/*
* Add resjunk entry to input's tlist
*/
- resdom = makeResdom(length(tlist) + 1,
+ resdom = makeResdom(list_length(tlist) + 1,
exprType(pathkey->key),
exprTypmod(pathkey->key),
NULL,
AttrNumber *sortColIdx;
Oid *sortOperators;
- /* We will need at most length(sortcls) sort columns; possibly less */
- numsortkeys = length(sortcls);
+ /* We will need at most list_length(sortcls) sort columns; possibly less */
+ numsortkeys = list_length(sortcls);
sortColIdx = (AttrNumber *) palloc(numsortkeys * sizeof(AttrNumber));
sortOperators = (Oid *) palloc(numsortkeys * sizeof(Oid));
AttrNumber *sortColIdx;
Oid *sortOperators;
- /* We will need at most length(groupcls) sort columns; possibly less */
- numsortkeys = length(groupcls);
+ /* We will need at most list_length(groupcls) sort columns; possibly less */
+ numsortkeys = list_length(groupcls);
sortColIdx = (AttrNumber *) palloc(numsortkeys * sizeof(AttrNumber));
sortOperators = (Oid *) palloc(numsortkeys * sizeof(Oid));
{
Unique *node = makeNode(Unique);
Plan *plan = &node->plan;
- int numCols = length(distinctList);
+ int numCols = list_length(distinctList);
int keyno = 0;
AttrNumber *uniqColIdx;
ListCell *slitem;
{
SetOp *node = makeNode(SetOp);
Plan *plan = &node->plan;
- int numCols = length(distinctList);
+ int numCols = list_length(distinctList);
int keyno = 0;
AttrNumber *dupColIdx;
ListCell *slitem;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.99 2004/05/26 04:41:24 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.100 2004/05/30 23:40:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
if (tlist_vars != NIL)
{
add_vars_to_targetlist(root, tlist_vars, bms_make_singleton(0));
- freeList(tlist_vars);
+ list_free(tlist_vars);
}
}
*/
if (rel->outerjoinset == NULL)
{
- if (intMember(relno, root->rowMarks))
+ if (list_member_int(root->rowMarks, relno))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("SELECT FOR UPDATE cannot be applied to the nullable side of an outer join")));
*/
vars = pull_var_clause(clause, false);
add_vars_to_targetlist(root, vars, relids);
- freeList(vars);
+ list_free(vars);
break;
default:
if (membership == BMS_SINGLETON)
{
/* delete it from local restrictinfo list */
- rel1->baserestrictinfo = lremove(restrictinfo,
- rel1->baserestrictinfo);
+ rel1->baserestrictinfo = list_delete_ptr(rel1->baserestrictinfo,
+ restrictinfo);
}
else
{
*/
ltype = exprType(item1);
rtype = exprType(item2);
- eq_operator = compatible_oper(makeList1(makeString("=")),
+ eq_operator = compatible_oper(list_make1(makeString("=")),
ltype, rtype, true);
if (!HeapTupleIsValid(eq_operator))
{
* done. We give up when we can't expand the equalexprs list any
* more.
*/
- equalexprs = makeList1(newleft);
+ equalexprs = list_make1(newleft);
do
{
someadded = false;
- /* cannot use foreach here because of possible lremove */
+ /* cannot use foreach here because of possible list_delete */
olditem = list_head(oldquals);
while (olditem)
{
Node *oldright = get_rightop(oldrinfo->clause);
Node *newguy = NULL;
- /* must advance olditem before lremove possibly pfree's it */
+ /* must advance olditem before list_delete possibly pfree's it */
olditem = lnext(olditem);
- if (member(oldleft, equalexprs))
+ if (list_member(equalexprs, oldleft))
newguy = oldright;
- else if (member(oldright, equalexprs))
+ else if (list_member(equalexprs, oldright))
newguy = oldleft;
else
continue;
/*
* Remove this qual from list, since we don't need it anymore.
*/
- oldquals = lremove(oldrinfo, oldquals);
+ oldquals = list_delete_ptr(oldquals, oldrinfo);
}
} while (someadded);
if (!is_opclause(clause))
return;
- if (length(((OpExpr *) clause)->args) != 2)
+ if (list_length(((OpExpr *) clause)->args) != 2)
return;
opno = ((OpExpr *) clause)->opno;
if (!is_opclause(clause))
return;
- if (length(((OpExpr *) clause)->args) != 2)
+ if (list_length(((OpExpr *) clause)->args) != 2)
return;
opno = ((OpExpr *) clause)->opno;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.170 2004/05/26 04:41:24 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.171 2004/05/30 23:40:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
}
/* executor wants to know total number of Params used overall */
- result_plan->nParamExec = length(PlannerParamList);
+ result_plan->nParamExec = list_length(PlannerParamList);
/* final cleanup of the plan */
set_plan_references(result_plan, parse->rtable);
{
int parentRTindex = parse->resultRelation;
Oid parentOID = getrelid(parentRTindex, parse->rtable);
- int mainrtlength = length(parse->rtable);
+ int mainrtlength = list_length(parse->rtable);
List *subplans = NIL;
List *tlist = NIL;
ListCell *l;
foreach(l, inheritlist)
{
- int childRTindex = lfirsti(l);
+ int childRTindex = lfirst_int(l);
Oid childOID = getrelid(childRTindex, parse->rtable);
int subrtlength;
Query *subquery;
* XXX my goodness this is ugly. Really need to think about ways to
* rein in planner's habit of scribbling on its input.
*/
- subrtlength = length(subquery->rtable);
+ subrtlength = list_length(subquery->rtable);
if (subrtlength > mainrtlength)
{
List *subrt;
subrt = list_copy_tail(subquery->rtable, mainrtlength);
- parse->rtable = nconc(parse->rtable, subrt);
+ parse->rtable = list_concat(parse->rtable, subrt);
mainrtlength = subrtlength;
}
/* Save preprocessed tlist from first rel for use in Append */
double dNumGroups = 0;
long numGroups = 0;
int numAggs = 0;
- int numGroupCols = length(parse->groupClause);
+ int numGroupCols = list_length(parse->groupClause);
bool use_hashed_grouping = false;
/* Preprocess targetlist in case we are inside an INSERT/UPDATE. */
foreach(l, parse->rowMarks)
{
- Index rti = lfirsti(l);
+ Index rti = lfirst_int(l);
char *resname;
Resdom *resdom;
Var *var;
resname = (char *) palloc(32);
snprintf(resname, 32, "ctid%u", rti);
- resdom = makeResdom(length(tlist) + 1,
+ resdom = makeResdom(list_length(tlist) + 1,
TIDOID,
-1,
resname,
sub_tlist = flatten_tlist(tlist);
extravars = pull_var_clause(parse->havingQual, false);
sub_tlist = add_to_flat_tlist(sub_tlist, extravars);
- freeList(extravars);
+ list_free(extravars);
*need_tlist_eval = false; /* only eval if not flat tlist */
/*
* already), and make an array showing where the group columns are in
* the sub_tlist.
*/
- numCols = length(parse->groupClause);
+ numCols = list_length(parse->groupClause);
if (numCols > 0)
{
int keyno = 0;
}
if (!sl)
{
- te = makeTargetEntry(makeResdom(length(sub_tlist) + 1,
+ te = makeTargetEntry(makeResdom(list_length(sub_tlist) + 1,
exprType(groupexpr),
exprTypmod(groupexpr),
NULL,
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.90 2004/05/26 04:41:24 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.91 2004/05/30 23:40:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
pitem->abslevel = abslevel;
PlannerParamList = lappend(PlannerParamList, pitem);
- i = length(PlannerParamList) - 1;
+ i = list_length(PlannerParamList) - 1;
retval = makeNode(Param);
retval->paramkind = PARAM_EXEC;
retval = makeNode(Param);
retval->paramkind = PARAM_EXEC;
- retval->paramid = (AttrNumber) length(PlannerParamList);
+ retval->paramid = (AttrNumber) list_length(PlannerParamList);
retval->paramtype = paramtype;
pitem = (PlannerParamItem *) palloc(sizeof(PlannerParamItem));
tmpset = bms_copy(plan->extParam);
while ((paramid = bms_first_member(tmpset)) >= 0)
{
- PlannerParamItem *pitem = nth(paramid, PlannerParamList);
+ PlannerParamItem *pitem = list_nth(PlannerParamList, paramid);
if (pitem->abslevel == PlannerQueryLevel)
- node->parParam = lappendi(node->parParam, paramid);
+ node->parParam = lappend_int(node->parParam, paramid);
}
bms_free(tmpset);
Param *prm;
prm = generate_new_param(BOOLOID, -1);
- node->setParam = makeListi1(prm->paramid);
+ node->setParam = list_make1_int(prm->paramid);
PlannerInitPlan = lappend(PlannerInitPlan, node);
result = (Node *) prm;
}
Assert(!te->resdom->resjunk);
prm = generate_new_param(te->resdom->restype, te->resdom->restypmod);
- node->setParam = makeListi1(prm->paramid);
+ node->setParam = list_make1_int(prm->paramid);
PlannerInitPlan = lappend(PlannerInitPlan, node);
result = (Node *) prm;
}
elog(ERROR, "could not find array type for datatype %s",
format_type_be(te->resdom->restype));
prm = generate_new_param(arraytype, -1);
- node->setParam = makeListi1(prm->paramid);
+ node->setParam = list_make1_int(prm->paramid);
PlannerInitPlan = lappend(PlannerInitPlan, node);
result = (Node *) prm;
}
plan->targetlist,
0,
&node->paramIds);
- node->setParam = listCopy(node->paramIds);
+ node->setParam = list_copy(node->paramIds);
PlannerInitPlan = lappend(PlannerInitPlan, node);
/*
* outer plan's expression tree; they are not kept in the initplan
* node.
*/
- if (length(exprs) > 1)
+ if (list_length(exprs) > 1)
result = (Node *) (node->useOr ? make_orclause(exprs) :
make_andclause(exprs));
else
args = NIL;
foreach(l, node->parParam)
{
- PlannerParamItem *pitem = nth(lfirsti(l), PlannerParamList);
+ PlannerParamItem *pitem = list_nth(PlannerParamList, lfirst_int(l));
/*
* The Var or Aggref has already been adjusted to have the
foreach(l, operOids)
{
- Oid opid = lfirsto(l);
+ Oid opid = lfirst_oid(l);
Node *leftop = (Node *) lfirst(lefthand_item);
TargetEntry *te = (TargetEntry *) lfirst(tlist_item);
Node *rightop;
prm = generate_new_param(te->resdom->restype,
te->resdom->restypmod);
/* Record its ID */
- *righthandIds = lappendi(*righthandIds, prm->paramid);
+ *righthandIds = lappend_int(*righthandIds, prm->paramid);
rightop = (Node *) prm;
}
*/
if (slink->subLinkType != ANY_SUBLINK)
return false;
- if (length(slink->operName) != 1 ||
+ if (list_length(slink->operName) != 1 ||
strcmp(strVal(linitial(slink->operName)), "=") != 0)
return false;
*/
foreach(l, slink->operOids)
{
- Oid opid = lfirsto(l);
+ Oid opid = lfirst_oid(l);
HeapTuple tup;
Form_pg_operator optup;
*/
if (sublink->subLinkType != ANY_SUBLINK)
return NULL;
- if (length(sublink->operName) != 1 ||
+ if (list_length(sublink->operName) != 1 ||
strcmp(strVal(linitial(sublink->operName)), "=") != 0)
return NULL;
makeAlias("IN_subquery", NIL),
false);
parse->rtable = lappend(parse->rtable, rte);
- rtindex = length(parse->rtable);
+ rtindex = list_length(parse->rtable);
rtr = makeNode(RangeTblRef);
rtr->rtindex = rtindex;
parse->jointree->fromlist = lappend(parse->jointree->fromlist, rtr);
newarg = process_sublinks_mutator(lfirst(l),
(void *) &locTopQual);
if (and_clause(newarg))
- newargs = nconc(newargs, ((BoolExpr *) newarg)->args);
+ newargs = list_concat(newargs, ((BoolExpr *) newarg)->args);
else
newargs = lappend(newargs, newarg);
}
newarg = process_sublinks_mutator(lfirst(l),
(void *) &locTopQual);
if (or_clause(newarg))
- newargs = nconc(newargs, ((BoolExpr *) newarg)->args);
+ newargs = list_concat(newargs, ((BoolExpr *) newarg)->args);
else
newargs = lappend(newargs, newarg);
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.19 2004/05/26 18:35:41 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.20 2004/05/30 23:40:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
* Adjust level-0 varnos in subquery so that we can append its
* rangetable to upper query's.
*/
- rtoffset = length(parse->rtable);
+ rtoffset = list_length(parse->rtable);
OffsetVarNodes((Node *) subquery, rtoffset, 0);
/*
* hold off until after fixing the upper rtable entries; no
* point in running that code on the subquery ones too.)
*/
- parse->rtable = nconc(parse->rtable, subquery->rtable);
+ parse->rtable = list_concat(parse->rtable, subquery->rtable);
/*
* Pull up any FOR UPDATE markers, too. (OffsetVarNodes
- * already adjusted the marker values, so just nconc the
- * list.)
+ * already adjusted the marker values, so just list_concat
+ * the list.)
*/
- parse->rowMarks = nconc(parse->rowMarks, subquery->rowMarks);
+ parse->rowMarks = list_concat(parse->rowMarks, subquery->rowMarks);
/*
* We also have to fix the relid sets of any parent
/*
* And now append any subquery InClauseInfos to our list.
*/
- parse->in_info_list = nconc(parse->in_info_list,
- subquery->in_info_list);
+ parse->in_info_list = list_concat(parse->in_info_list,
+ subquery->in_info_list);
/*
* Miscellaneous housekeeping.
pass_nonnullable = bms_add_members(pass_nonnullable,
nonnullable_rels);
/* And recurse --- but only into interesting subtrees */
- Assert(length(f->fromlist) == length(state->sub_states));
+ Assert(list_length(f->fromlist) == list_length(state->sub_states));
forboth(l, f->fromlist, s, state->sub_states)
{
reduce_outer_joins_state *sub_state = lfirst(s);
* from_collapse_limit.
*/
FromExpr *subf = (FromExpr *) child;
- int childlen = length(subf->fromlist);
- int myothers = length(newlist) + children_remaining;
+ int childlen = list_length(subf->fromlist);
+ int myothers = list_length(newlist) + children_remaining;
if (childlen <= 1 ||
(childlen + myothers) <= from_collapse_limit)
{
- newlist = nconc(newlist, subf->fromlist);
+ newlist = list_concat(newlist, subf->fromlist);
/*
* By now, the quals have been converted to
* implicit-AND lists, so we just need to join the
* lists. NOTE: we put the pulled-up quals first.
*/
- f->quals = (Node *) nconc((List *) subf->quals,
+ f->quals = (Node *) list_concat((List *) subf->quals,
(List *) f->quals);
}
else
rightlen;
if (j->larg && IsA(j->larg, FromExpr))
- leftlen = length(((FromExpr *) j->larg)->fromlist);
+ leftlen = list_length(((FromExpr *) j->larg)->fromlist);
else
leftlen = 1;
if (j->rarg && IsA(j->rarg, FromExpr))
- rightlen = length(((FromExpr *) j->rarg)->fromlist);
+ rightlen = list_length(((FromExpr *) j->rarg)->fromlist);
else
rightlen = 1;
if ((leftlen + rightlen) <= join_collapse_limit)
f->quals = subf->quals;
}
else
- f->fromlist = makeList1(j->larg);
+ f->fromlist = list_make1(j->larg);
if (j->rarg && IsA(j->rarg, FromExpr))
{
FromExpr *subf = (FromExpr *) j->rarg;
- f->fromlist = nconc(f->fromlist,
- subf->fromlist);
- f->quals = (Node *) nconc((List *) f->quals,
+ f->fromlist = list_concat(f->fromlist,
+ subf->fromlist);
+ f->quals = (Node *) list_concat((List *) f->quals,
(List *) subf->quals);
}
else
f->fromlist = lappend(f->fromlist, j->rarg);
/* pulled-up quals first */
- f->quals = (Node *) nconc((List *) f->quals,
+ f->quals = (Node *) list_concat((List *) f->quals,
(List *) j->quals);
return (Node *) f;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepqual.c,v 1.42 2004/05/26 04:41:26 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepqual.c,v 1.43 2004/05/30 23:40:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
if (orlist == NIL)
return NULL; /* probably can't happen */
- if (length(orlist) == 1) /* single-expression OR (can this happen?) */
+ if (list_length(orlist) == 1) /* single-expression OR (can this happen?) */
return linitial(orlist);
/*
if (and_clause((Node *) clause))
{
List *subclauses = ((BoolExpr *) clause)->args;
- int nclauses = length(subclauses);
+ int nclauses = list_length(subclauses);
if (reference == NIL || nclauses < num_subclauses)
{
}
else
{
- reference = makeList1(clause);
+ reference = list_make1(clause);
break;
}
}
/*
* Just in case, eliminate any duplicates in the reference list.
*/
- reference = set_union(NIL, reference);
+ reference = list_union(NIL, reference);
/*
* Check each element of the reference list to see if it's in all the
if (and_clause((Node *) clause))
{
- if (!member(refclause, ((BoolExpr *) clause)->args))
+ if (!list_member(((BoolExpr *) clause)->args, refclause))
{
win = false;
break;
* (A AND B) OR (A), which can be reduced to just A --- that is, the
* additional conditions in other arms of the OR are irrelevant.
*
- * Note that because we use set_difference, any multiple occurrences of
+ * Note that because we use list_difference, any multiple occurrences of
* a winning clause in an AND sub-clause will be removed automatically.
*/
neworlist = NIL;
{
List *subclauses = ((BoolExpr *) clause)->args;
- subclauses = set_difference(subclauses, winners);
+ subclauses = list_difference(subclauses, winners);
if (subclauses != NIL)
{
- if (length(subclauses) == 1)
+ if (list_length(subclauses) == 1)
neworlist = lappend(neworlist, linitial(subclauses));
else
neworlist = lappend(neworlist, make_andclause(subclauses));
}
else
{
- if (!member(clause, winners))
+ if (!list_member(winners, clause))
neworlist = lappend(neworlist, clause);
else
{
*/
if (neworlist != NIL)
{
- if (length(neworlist) == 1)
+ if (list_length(neworlist) == 1)
winners = lappend(winners, linitial(neworlist));
else
winners = lappend(winners, make_orclause(pull_ors(neworlist)));
* And return the constructed AND clause, again being wary of a single
* element and AND/OR flatness.
*/
- if (length(winners) == 1)
+ if (list_length(winners) == 1)
return (Expr *) linitial(winners);
else
return make_andclause(pull_ands(winners));
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/prep/preptlist.c,v 1.67 2004/05/26 04:41:26 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/prep/preptlist.c,v 1.68 2004/05/30 23:40:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
Resdom *resdom;
Var *var;
- resdom = makeResdom(length(tlist) + 1,
+ resdom = makeResdom(list_length(tlist) + 1,
TIDOID,
-1,
pstrdup("ctid"),
* modify the original tlist (is this really necessary?).
*/
if (command_type == CMD_DELETE)
- tlist = listCopy(tlist);
+ tlist = list_copy(tlist);
tlist = lappend(tlist, makeTargetEntry(resdom, (Expr *) var));
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.111 2004/05/26 04:41:26 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.112 2004/05/30 23:40:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
* generate only one Append and Sort for the lot. Recurse to find
* such nodes and compute their children's plans.
*/
- planlist = nconc(recurse_union_children(op->larg, parse,
- op, refnames_tlist),
- recurse_union_children(op->rarg, parse,
- op, refnames_tlist));
+ planlist = list_concat(recurse_union_children(op->larg, parse,
+ op, refnames_tlist),
+ recurse_union_children(op->rarg, parse,
+ op, refnames_tlist));
/*
* Generate tlist for Append plan node.
op->colTypes, false, 1,
refnames_tlist,
&child_sortclauses);
- planlist = makeList2(lplan, rplan);
+ planlist = list_make2(lplan, rplan);
/*
* Generate tlist for Append plan node.
cmd = SETOPCMD_INTERSECT; /* keep compiler quiet */
break;
}
- plan = (Plan *) make_setop(cmd, plan, sortList, length(op->colTypes) + 1);
+ plan = (Plan *) make_setop(cmd, plan, sortList, list_length(op->colTypes) + 1);
*sortClauses = sortList;
if (op->op == top_union->op &&
(op->all == top_union->all || op->all) &&
- equalo(op->colTypes, top_union->colTypes))
+ equal(op->colTypes, top_union->colTypes))
{
/* Same UNION, so fold children into parent's subplan list */
- return nconc(recurse_union_children(op->larg, parse,
- top_union,
- refnames_tlist),
- recurse_union_children(op->rarg, parse,
- top_union,
- refnames_tlist));
+ return list_concat(recurse_union_children(op->larg, parse,
+ top_union,
+ refnames_tlist),
+ recurse_union_children(op->rarg, parse,
+ top_union,
+ refnames_tlist));
}
}
* we have an EXCEPT or INTERSECT as child, else there won't be
* resjunk anyway.
*/
- return makeList1(recurse_set_operations(setOp, parse,
- top_union->colTypes, false,
- -1, refnames_tlist,
- &child_sortclauses));
+ return list_make1(recurse_set_operations(setOp, parse,
+ top_union->colTypes, false,
+ -1, refnames_tlist,
+ &child_sortclauses));
}
/*
k = list_head(refnames_tlist);
foreach(i, colTypes)
{
- Oid colType = lfirsto(i);
+ Oid colType = lfirst_oid(i);
TargetEntry *inputtle = (TargetEntry *) lfirst(j);
TargetEntry *reftle = (TargetEntry *) lfirst(k);
int32 colTypmod;
* If the inputs all agree on type and typmod of a particular column, use
* that typmod; else use -1. (+1 here in case of zero columns.)
*/
- colTypmods = (int32 *) palloc(length(colTypes) * sizeof(int32) + 1);
+ colTypmods = (int32 *) palloc(list_length(colTypes) * sizeof(int32) + 1);
foreach(planl, input_plans)
{
colindex = 0;
forboth(curColType, colTypes, ref_tl_item, refnames_tlist)
{
- Oid colType = lfirsto(curColType);
+ Oid colType = lfirst_oid(curColType);
int32 colTypmod = colTypmods[colindex++];
TargetEntry *reftle = (TargetEntry *) lfirst(ref_tl_item);
find_all_inheritors(Oid parentrel)
{
List *examined_relids = NIL;
- List *unexamined_relids = makeListo1(parentrel);
+ List *unexamined_relids = list_make1_oid(parentrel);
/*
* While the queue of unexamined relids is nonempty, remove the first
List *currentchildren;
unexamined_relids = list_delete_first(unexamined_relids);
- examined_relids = lappendo(examined_relids, currentrel);
+ examined_relids = lappend_oid(examined_relids, currentrel);
currentchildren = find_inheritance_children(currentrel);
/*
* into an infinite loop, though theoretically there can't be any
* cycles in the inheritance graph anyway.)
*/
- currentchildren = set_differenceo(currentchildren, examined_relids);
- unexamined_relids = set_uniono(unexamined_relids, currentchildren);
+ currentchildren = list_difference_oid(currentchildren, examined_relids);
+ unexamined_relids = list_union_oid(unexamined_relids, currentchildren);
}
return examined_relids;
* case. This could happen despite above has_subclass() check, if
* table once had a child but no longer does.
*/
- if (length(inhOIDs) < 2)
+ if (list_length(inhOIDs) < 2)
return NIL;
/* OK, it's an inheritance set; expand it */
if (dup_parent)
inhRTIs = NIL;
else
- inhRTIs = makeListi1(rti); /* include original RTE in result */
+ inhRTIs = list_make1_int(rti); /* include original RTE in result */
foreach(l, inhOIDs)
{
- Oid childOID = lfirsto(l);
+ Oid childOID = lfirst_oid(l);
RangeTblEntry *childrte;
Index childRTindex;
childrte = copyObject(rte);
childrte->relid = childOID;
parse->rtable = lappend(parse->rtable, childrte);
- childRTindex = length(parse->rtable);
+ childRTindex = list_length(parse->rtable);
- inhRTIs = lappendi(inhRTIs, childRTindex);
+ inhRTIs = lappend_int(inhRTIs, childRTindex);
}
return inhRTIs;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.171 2004/05/26 04:41:27 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.172 2004/05/30 23:40:30 neilc Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
expr->opresulttype = opresulttype;
expr->opretset = opretset;
if (rightop)
- expr->args = makeList2(leftop, rightop);
+ expr->args = list_make2(leftop, rightop);
else
- expr->args = makeList1(leftop);
+ expr->args = list_make1(leftop);
return (Expr *) expr;
}
BoolExpr *expr = makeNode(BoolExpr);
expr->boolop = NOT_EXPR;
- expr->args = makeList1(notclause);
+ expr->args = list_make1(notclause);
return (Expr *) expr;
}
return qual2;
if (qual2 == NULL)
return qual1;
- return (Node *) make_andclause(makeList2(qual1, qual2));
+ return (Node *) make_andclause(list_make2(qual1, qual2));
}
/*
{
if (andclauses == NIL)
return (Expr *) makeBoolConst(true, false);
- else if (length(andclauses) == 1)
+ else if (list_length(andclauses) == 1)
return (Expr *) linitial(andclauses);
else
return make_andclause(andclauses);
DatumGetBool(((Const *) clause)->constvalue))
return NIL; /* constant TRUE input -> NIL list */
else
- return makeList1(clause);
+ return list_make1(clause);
}
foreach(opid, sublink->operOids)
{
- if (op_volatile(lfirsto(opid)) != PROVOLATILE_IMMUTABLE)
+ if (op_volatile(lfirst_oid(opid)) != PROVOLATILE_IMMUTABLE)
return true;
}
/* else fall through to check args */
foreach(opid, sublink->operOids)
{
- if (op_volatile(lfirsto(opid)) == PROVOLATILE_VOLATILE)
+ if (op_volatile(lfirst_oid(opid)) == PROVOLATILE_VOLATILE)
return true;
}
/* else fall through to check args */
/* Sanity checks: caller is at fault if these fail */
if (!is_opclause(clause) ||
- length(clause->args) != 2)
+ list_length(clause->args) != 2)
elog(ERROR, "cannot commute non-binary-operator clause");
opoid = get_commutator(clause->opno);
if (newargs == NIL)
return makeBoolConst(false, false);
/* If only one nonconst-or-NULL input, it's the result */
- if (length(newargs) == 1)
+ if (list_length(newargs) == 1)
return (Node *) linitial(newargs);
/* Else we still need an OR node */
return (Node *) make_orclause(newargs);
if (newargs == NIL)
return makeBoolConst(true, false);
/* If only one nonconst-or-NULL input, it's the result */
- if (length(newargs) == 1)
+ if (list_length(newargs) == 1)
return (Node *) linitial(newargs);
/* Else we still need an AND node */
return (Node *) make_andclause(newargs);
}
case NOT_EXPR:
- Assert(length(args) == 1);
+ Assert(list_length(args) == 1);
if (IsA(linitial(args), Const))
{
Const *const_input = (Const *) linitial(args);
RowExpr *rowexpr = (RowExpr *) arg;
if (fselect->fieldnum > 0 &&
- fselect->fieldnum <= length(rowexpr->args))
- return (Node *) nth(fselect->fieldnum - 1, rowexpr->args);
+ fselect->fieldnum <= list_length(rowexpr->args))
+ return (Node *) list_nth(rowexpr->args, fselect->fieldnum - 1);
}
newfselect = makeNode(FieldSelect);
newfselect->arg = (Expr *) arg;
}
else if (or_clause(arg))
{
- newargs = nconc(newargs,
- simplify_or_arguments(((BoolExpr *) arg)->args,
- haveNull, forceTrue));
+ newargs = list_concat(newargs,
+ simplify_or_arguments(((BoolExpr *) arg)->args,
+ haveNull, forceTrue));
}
else
{
}
else if (and_clause(arg))
{
- newargs = nconc(newargs,
- simplify_and_arguments(((BoolExpr *) arg)->args,
- haveNull, forceFalse));
+ newargs = list_concat(newargs,
+ simplify_and_arguments(((BoolExpr *) arg)->args,
+ haveNull, forceFalse));
}
else
{
if (funcform->prolang != SQLlanguageId ||
funcform->prosecdef ||
funcform->proretset ||
- funcform->pronargs != length(args))
+ funcform->pronargs != list_length(args))
return NULL;
/* Check for recursive function, and give up trying to expand if so */
- if (oidMember(funcid, active_fns))
+ if (list_member_oid(active_fns, funcid))
return NULL;
/* Check permission to call function (fail later, if not) */
argtypes[i] == ANYELEMENTOID)
{
polymorphic = true;
- argtypes[i] = exprType((Node *) nth(i, args));
+ argtypes[i] = exprType((Node *) list_nth(args, i));
}
}
* more than one command in the function body.
*/
raw_parsetree_list = pg_parse_query(src);
- if (length(raw_parsetree_list) != 1)
+ if (list_length(raw_parsetree_list) != 1)
goto fail;
querytree_list = parse_analyze(linitial(raw_parsetree_list),
argtypes, funcform->pronargs);
- if (length(querytree_list) != 1)
+ if (list_length(querytree_list) != 1)
goto fail;
querytree = (Query *) linitial(querytree_list);
querytree->limitOffset ||
querytree->limitCount ||
querytree->setOperations ||
- length(querytree->targetList) != 1)
+ list_length(querytree->targetList) != 1)
goto fail;
newexpr = (Node *) ((TargetEntry *) linitial(querytree->targetList))->expr;
*/
if (contain_subplans(param))
goto fail;
- cost_qual_eval(&eval_cost, makeList1(param));
+ cost_qual_eval(&eval_cost, list_make1(param));
if (eval_cost.startup + eval_cost.per_tuple >
10 * cpu_operator_cost)
goto fail;
* add the current function to the context list of active functions.
*/
newexpr = eval_const_expressions_mutator(newexpr,
- lconso(funcid, active_fns));
+ lcons_oid(funcid, active_fns));
error_context_stack = sqlerrcontext.previous;
/* Select the appropriate actual arg and replace the Param with it */
/* We don't need to copy at this time (it'll get done later) */
- return nth(param->paramid - 1, context->args);
+ return list_nth(context->args, param->paramid - 1);
}
return expression_tree_mutator(node, substitute_actual_parameters_mutator,
(void *) context);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/joininfo.c,v 1.38 2004/05/26 04:41:27 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/joininfo.c,v 1.39 2004/05/30 23:40:31 neilc Exp $
*
*-------------------------------------------------------------------------
*/
* Remove the restrictinfo from the list. Pointer comparison is
* sufficient.
*/
- Assert(ptrMember(restrictinfo, joininfo->jinfo_restrictinfo));
- joininfo->jinfo_restrictinfo = lremove(restrictinfo,
- joininfo->jinfo_restrictinfo);
+ Assert(list_member_ptr(joininfo->jinfo_restrictinfo, restrictinfo));
+ joininfo->jinfo_restrictinfo = list_delete_ptr(joininfo->jinfo_restrictinfo,
+ restrictinfo);
bms_free(unjoined_relids);
}
bms_free(tmprelids);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.105 2004/05/26 04:41:27 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.106 2004/05/30 23:40:31 neilc Exp $
*
*-------------------------------------------------------------------------
*/
* We are making a pathnode for a single-scan indexscan; therefore,
* indexinfo etc should be single-element lists.
*/
- pathnode->indexinfo = makeList1(index);
- pathnode->indexclauses = makeList1(restriction_clauses);
- pathnode->indexquals = makeList1(indexquals);
+ pathnode->indexinfo = list_make1(index);
+ pathnode->indexclauses = list_make1(restriction_clauses);
+ pathnode->indexquals = list_make1(indexquals);
/* It's not an innerjoin path. */
pathnode->isjoininner = false;
if (sub_targetlist)
{
pathnode->rows = estimate_num_groups(root, sub_targetlist, rel->rows);
- numCols = length(sub_targetlist);
+ numCols = list_length(sub_targetlist);
}
else
{
pathnode->rows = rel->rows;
- numCols = length(FastListValue(&rel->reltargetlist));
+ numCols = list_length(FastListValue(&rel->reltargetlist));
}
/*
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.92 2004/05/26 04:41:27 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.93 2004/05/30 23:40:31 neilc Exp $
*
*-------------------------------------------------------------------------
*/
foreach(l, indexoidlist)
{
- Oid indexoid = lfirsto(l);
+ Oid indexoid = lfirst_oid(l);
Relation indexRelation;
Form_pg_index index;
IndexOptInfo *info;
indexinfos = lcons(info, indexinfos);
}
- freeList(indexoidlist);
+ list_free(indexoidlist);
}
rel->indexlist = indexinfos;
while ((inheritsTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
inhrelid = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhrelid;
- list = lappendo(list, inhrelid);
+ list = lappend_oid(list, inhrelid);
}
heap_endscan(scan);
heap_close(relation, AccessShareLock);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.57 2004/05/26 04:41:27 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.58 2004/05/30 23:40:31 neilc Exp $
*
*-------------------------------------------------------------------------
*/
/* Subquery or function --- need only set up attr range */
/* Note: 0 is included in range to support whole-row Vars */
rel->min_attr = 0;
- rel->max_attr = length(rte->eref->colnames);
+ rel->max_attr = list_length(rte->eref->colnames);
break;
default:
elog(ERROR, "unrecognized RTE kind: %d",
/*
* Collect all the clauses that syntactically belong at this level.
*/
- rlist = nconc(subbuild_joinrel_restrictlist(joinrel,
- outer_rel->joininfo),
- subbuild_joinrel_restrictlist(joinrel,
- inner_rel->joininfo));
+ rlist = list_concat(subbuild_joinrel_restrictlist(joinrel,
+ outer_rel->joininfo),
+ subbuild_joinrel_restrictlist(joinrel,
+ inner_rel->joininfo));
/*
* Eliminate duplicate and redundant clauses.
*/
result = remove_redundant_join_clauses(root, rlist, jointype);
- freeList(rlist);
+ list_free(rlist);
return result;
}
* We must copy the list to avoid disturbing the input relation,
* but we can use a shallow copy.
*/
- restrictlist = nconc(restrictlist,
- listCopy(joininfo->jinfo_restrictinfo));
+ restrictlist = list_concat(restrictlist,
+ list_copy(joininfo->jinfo_restrictinfo));
}
else
{
new_joininfo = make_joininfo_node(joinrel, new_unjoined_relids);
new_joininfo->jinfo_restrictinfo =
- set_ptrUnion(new_joininfo->jinfo_restrictinfo,
- joininfo->jinfo_restrictinfo);
+ list_union_ptr(new_joininfo->jinfo_restrictinfo,
+ joininfo->jinfo_restrictinfo);
}
}
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.27 2004/05/26 04:41:27 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.28 2004/05/30 23:40:31 neilc Exp $
*
*-------------------------------------------------------------------------
*/
if (indexclauses == NIL)
return NIL;
/* If single indexscan, just return the ANDed clauses */
- if (length(indexclauses) == 1)
+ if (list_length(indexclauses) == 1)
return (List *) linitial(indexclauses);
/* Else we need an OR RestrictInfo structure */
foreach(orlist, indexclauses)
andlist = get_actual_clauses(andlist);
withoutris = lappend(withoutris, make_ands_explicit(andlist));
}
- return makeList1(make_restrictinfo_internal(make_orclause(withoutris),
+ return list_make1(make_restrictinfo_internal(make_orclause(withoutris),
make_orclause(withris),
is_pushed_down,
valid_everywhere));
* If it's a binary opclause, set up left/right relids info.
* In any case set up the total clause relids info.
*/
- if (is_opclause(clause) && length(((OpExpr *) clause)->args) == 2)
+ if (is_opclause(clause) && list_length(((OpExpr *) clause)->args) == 2)
{
restrictinfo->left_relids = pull_varnos(get_leftop(clause));
restrictinfo->right_relids = pull_varnos(get_rightop(clause));
else if (CLAUSECOST(rinfo) < CLAUSECOST(prevrinfo))
{
/* keep this one, drop the previous one */
- result = lremove(prevrinfo, result);
+ result = list_delete_ptr(result, prevrinfo);
result = lappend(result, rinfo);
}
/* else, drop this one */
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/tlist.c,v 1.63 2004/05/26 04:41:27 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/tlist.c,v 1.64 2004/05/30 23:40:31 neilc Exp $
*
*-------------------------------------------------------------------------
*/
List *new_tlist;
new_tlist = add_to_flat_tlist(NIL, vlist);
- freeList(vlist);
+ list_free(vlist);
return new_tlist;
}
List *
add_to_flat_tlist(List *tlist, List *vars)
{
- int next_resdomno = length(tlist) + 1;
+ int next_resdomno = list_length(tlist) + 1;
ListCell *v;
foreach(v, vars)
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/var.c,v 1.57 2004/05/26 04:41:27 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/var.c,v 1.58 2004/05/30 23:40:31 neilc Exp $
*
*-------------------------------------------------------------------------
*/
/* Expand join alias reference */
Assert(var->varattno > 0);
- newvar = (Node *) nth(var->varattno - 1, rte->joinaliasvars);
+ newvar = (Node *) list_nth(rte->joinaliasvars, var->varattno - 1);
/*
* If we are expanding an alias carried down from an upper query,
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.301 2004/05/26 04:41:29 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.302 2004/05/30 23:40:32 neilc Exp $
*
*-------------------------------------------------------------------------
*/
release_pstate_resources(pstate);
foreach(l, extras_before)
- result = nconc(result, parse_sub_analyze(lfirst(l), pstate));
+ result = list_concat(result, parse_sub_analyze(lfirst(l), pstate));
result = lappend(result, query);
foreach(l, extras_after)
- result = nconc(result, parse_sub_analyze(lfirst(l), pstate));
+ result = list_concat(result, parse_sub_analyze(lfirst(l), pstate));
/*
* Make sure that only the original query is marked original. We have
true);
rtr = makeNode(RangeTblRef);
/* assume new rte is at end */
- rtr->rtindex = length(pstate->p_rtable);
+ rtr->rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(rtr->rtindex, pstate->p_rtable));
pstate->p_joinlist = lappend(pstate->p_joinlist, rtr);
Assert(IsA(col, ResTarget));
Assert(!tle->resdom->resjunk);
- updateTargetListEntry(pstate, tle, col->name, lfirsti(attnos),
+ updateTargetListEntry(pstate, tle, col->name, lfirst_int(attnos),
col->indirection);
icols = lnext(icols);
q->utilityStmt = (Node *) stmt;
stmt->tableElts = cxt.columns;
stmt->constraints = cxt.ckconstraints;
- *extras_before = nconc(*extras_before, cxt.blist);
- *extras_after = nconc(cxt.alist, *extras_after);
+ *extras_before = list_concat(*extras_before, cxt.blist);
+ *extras_after = list_concat(cxt.alist, *extras_after);
return q;
}
/* Check for SERIAL pseudo-types */
is_serial = false;
- if (length(column->typename->names) == 1)
+ if (list_length(column->typename->names) == 1)
{
char *typname = strVal(linitial(column->typename->names));
snamenode->val.val.str = qstring;
funccallnode = makeNode(FuncCall);
funccallnode->funcname = SystemFuncName("nextval");
- funccallnode->args = makeList1(snamenode);
+ funccallnode->args = list_make1(snamenode);
funccallnode->agg_star = false;
funccallnode->agg_distinct = false;
{
FkConstraint *fkconstraint = (FkConstraint *) constraint;
- fkconstraint->fk_attrs = makeList1(makeString(column->colname));
+ fkconstraint->fk_attrs = list_make1(makeString(column->colname));
cxt->fkconstraints = lappend(cxt->fkconstraints, fkconstraint);
continue;
}
NULL,
"pkey");
if (constraint->keys == NIL)
- constraint->keys = makeList1(makeString(column->colname));
+ constraint->keys = list_make1(makeString(column->colname));
cxt->ixconstraints = lappend(cxt->ixconstraints, constraint);
break;
column->colname,
"key");
if (constraint->keys == NIL)
- constraint->keys = makeList1(makeString(column->colname));
+ constraint->keys = list_make1(makeString(column->colname));
cxt->ixconstraints = lappend(cxt->ixconstraints, constraint);
break;
if (cxt->pkey != NULL)
{
/* Make sure we keep the PKEY index in preference to others... */
- cxt->alist = makeList1(cxt->pkey);
+ cxt->alist = list_make1(cxt->pkey);
}
foreach(l, indexlist)
stmt->whereClause = transformWhereClause(pstate, stmt->whereClause,
"WHERE");
- if (length(pstate->p_rtable) != 2) /* naughty, naughty... */
+ if (list_length(pstate->p_rtable) != 2) /* naughty, naughty... */
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("rule WHERE condition may not contain references to other relations")));
nothing_qry->rtable = pstate->p_rtable;
nothing_qry->jointree = makeFromExpr(NIL, NULL); /* no join wanted */
- stmt->actions = makeList1(nothing_qry);
+ stmt->actions = list_make1(nothing_qry);
}
else
{
foreach(dtlist, sostmt->colTypes)
{
- Oid colType = lfirsto(dtlist);
+ Oid colType = lfirst_oid(dtlist);
Resdom *leftResdom;
char *colName;
Resdom *resdom;
jrtr->rtindex = 1; /* only entry in dummy rtable */
sv_rtable = pstate->p_rtable;
- pstate->p_rtable = makeList1(jrte);
+ pstate->p_rtable = list_make1(jrte);
sv_namespace = pstate->p_namespace;
- pstate->p_namespace = makeList1(jrtr);
+ pstate->p_namespace = list_make1(jrtr);
/*
* For now, we don't support resjunk sort clauses on the output of a
* selecting an output column by name or number. Enforce by checking
* that transformSortClause doesn't add any items to tlist.
*/
- tllen = length(qry->targetList);
+ tllen = list_length(qry->targetList);
qry->sortClause = transformSortClause(pstate,
sortClause,
pstate->p_namespace = sv_namespace;
pstate->p_rtable = sv_rtable;
- if (tllen != length(qry->targetList))
+ if (tllen != list_length(qry->targetList))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("ORDER BY on a UNION/INTERSECT/EXCEPT result must be on one of the result columns")));
*/
selectList = parse_sub_analyze((Node *) stmt, pstate);
- Assert(length(selectList) == 1);
+ Assert(list_length(selectList) == 1);
selectQuery = (Query *) linitial(selectList);
Assert(IsA(selectQuery, Query));
* Make the leaf query be a subquery in the top-level rangetable.
*/
snprintf(selectName, sizeof(selectName), "*SELECT* %d",
- length(pstate->p_rtable) + 1);
+ list_length(pstate->p_rtable) + 1);
rte = addRangeTableEntryForSubquery(pstate,
selectQuery,
makeAlias(selectName, NIL),
*/
rtr = makeNode(RangeTblRef);
/* assume new rte is at end */
- rtr->rtindex = length(pstate->p_rtable);
+ rtr->rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(rtr->rtindex, pstate->p_rtable));
return (Node *) rtr;
}
*/
lcoltypes = getSetColTypes(pstate, op->larg);
rcoltypes = getSetColTypes(pstate, op->rarg);
- if (length(lcoltypes) != length(rcoltypes))
+ if (list_length(lcoltypes) != list_length(rcoltypes))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("each %s query must have the same number of columns",
op->colTypes = NIL;
forboth(l, lcoltypes, r, rcoltypes)
{
- Oid lcoltype = lfirsto(l);
- Oid rcoltype = lfirsto(r);
+ Oid lcoltype = lfirst_oid(l);
+ Oid rcoltype = lfirst_oid(r);
Oid rescoltype;
- rescoltype = select_common_type(makeListo2(lcoltype, rcoltype),
+ rescoltype = select_common_type(list_make2_oid(lcoltype, rcoltype),
context);
- op->colTypes = lappendo(op->colTypes, rescoltype);
+ op->colTypes = lappend_oid(op->colTypes, rescoltype);
}
return (Node *) op;
if (resnode->resjunk)
continue;
- result = lappendo(result, resnode->restype);
+ result = lappend_oid(result, resnode->restype);
}
return result;
}
ListCell *dst_item = list_head(dst);
ListCell *src_item = list_head(src);
- if (length(src) > length(dst))
+ if (list_length(src) > list_length(dst))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("CREATE TABLE AS specifies too many column names")));
qry->commandType = CMD_UTILITY;
qry->utilityStmt = (Node *) stmt;
- *extras_before = nconc(*extras_before, cxt.blist);
- *extras_after = nconc(cxt.alist, *extras_after);
+ *extras_before = list_concat(*extras_before, cxt.blist);
+ *extras_after = list_concat(cxt.alist, *extras_after);
return qry;
}
result->utilityStmt = (Node *) stmt;
/* Transform list of TypeNames to list (and array) of type OIDs */
- nargs = length(stmt->argtypes);
+ nargs = list_length(stmt->argtypes);
if (nargs)
{
TypeName *tn = lfirst(l);
Oid toid = typenameTypeId(tn);
- argtype_oids = lappendo(argtype_oids, toid);
+ argtype_oids = lappend_oid(argtype_oids, toid);
argtoids[i++] = toid;
}
}
* Shouldn't get any extra statements, since grammar only allows
* OptimizableStmt
*/
- if (length(queries) != 1)
+ if (list_length(queries) != 1)
elog(ERROR, "unexpected extra stuff in prepared statement");
stmt->query = linitial(queries);
if (stmt->params || paramtypes)
{
- int nparams = length(stmt->params);
- int nexpected = length(paramtypes);
+ int nparams = list_length(stmt->params);
+ int nexpected = list_length(paramtypes);
ListCell *l, *l2;
int i = 1;
forboth(l, stmt->params, l2, paramtypes)
{
Node *expr = lfirst(l);
- Oid expected_type_id = lfirsto(l2);
+ Oid expected_type_id = lfirst_oid(l2);
Oid given_type_id;
expr = transformExpr(pstate, expr);
switch (rte->rtekind)
{
case RTE_RELATION:
- if (!intMember(i, rowMarks)) /* avoid duplicates */
- rowMarks = lappendi(rowMarks, i);
+ if (!list_member_int(rowMarks, i)) /* avoid duplicates */
+ rowMarks = lappend_int(rowMarks, i);
rte->requiredPerms |= ACL_SELECT_FOR_UPDATE;
break;
case RTE_SUBQUERY:
* FOR UPDATE of subquery is propagated to subquery's
* rels
*/
- transformForUpdate(rte->subquery, makeList1(NULL));
+ transformForUpdate(rte->subquery, list_make1(NULL));
break;
default:
/* ignore JOIN, SPECIAL, FUNCTION RTEs */
switch (rte->rtekind)
{
case RTE_RELATION:
- if (!intMember(i, rowMarks)) /* avoid duplicates */
- rowMarks = lappendi(rowMarks, i);
+ if (!list_member_int(rowMarks, i)) /* avoid duplicates */
+ rowMarks = lappend_int(rowMarks, i);
rte->requiredPerms |= ACL_SELECT_FOR_UPDATE;
break;
case RTE_SUBQUERY:
* FOR UPDATE of subquery is propagated to
* subquery's rels
*/
- transformForUpdate(rte->subquery, makeList1(NULL));
+ transformForUpdate(rte->subquery, list_make1(NULL));
break;
case RTE_JOIN:
ereport(ERROR,
}
result = NIL;
- result = nconc(result, cxt.sequences);
- result = nconc(result, cxt.tables);
- result = nconc(result, cxt.views);
- result = nconc(result, cxt.indexes);
- result = nconc(result, cxt.triggers);
- result = nconc(result, cxt.grants);
+ result = list_concat(result, cxt.sequences);
+ result = list_concat(result, cxt.tables);
+ result = list_concat(result, cxt.views);
+ result = list_concat(result, cxt.indexes);
+ result = list_concat(result, cxt.triggers);
+ result = list_concat(result, cxt.grants);
return result;
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.457 2004/05/26 15:07:37 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.458 2004/05/30 23:40:34 neilc Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
}
| stmt
{ if ($1 != NULL)
- $$ = makeList1($1);
+ $$ = list_make1($1);
else
$$ = NIL;
}
;
user_list: user_list ',' UserId { $$ = lappend($1, makeString($3)); }
- | UserId { $$ = makeList1(makeString($1)); }
+ | UserId { $$ = list_make1(makeString($1)); }
;
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "timezone";
if ($3 != NULL)
- n->args = makeList1($3);
+ n->args = list_make1($3);
$$ = n;
}
| TRANSACTION transaction_mode_list
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "client_encoding";
if ($2 != NULL)
- n->args = makeList1(makeStringConst($2, NULL));
+ n->args = list_make1(makeStringConst($2, NULL));
$$ = n;
}
| SESSION AUTHORIZATION ColId_or_Sconst
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "session_authorization";
- n->args = makeList1(makeStringConst($3, NULL));
+ n->args = list_make1(makeStringConst($3, NULL));
$$ = n;
}
| SESSION AUTHORIZATION DEFAULT
| DEFAULT { $$ = NIL; }
;
-var_list: var_value { $$ = makeList1($1); }
+var_list: var_value { $$ = list_make1($1); }
| var_list ',' var_value { $$ = lappend($1, $3); }
;
;
alter_table_cmds:
- alter_table_cmd { $$ = makeList1($1); }
+ alter_table_cmd { $$ = list_make1($1); }
| alter_table_cmds ',' alter_table_cmd { $$ = lappend($1, $3); }
;
if ($8)
n->options = lappend(n->options, $8);
if ($10)
- n->options = nconc(n->options, $10);
+ n->options = list_concat(n->options, $10);
$$ = (Node *)n;
}
;
$4->istemp = $2;
n->relation = $4;
n->tableElts = $8;
- n->inhRelations = makeList1($6);
+ n->inhRelations = list_make1($6);
n->constraints = NIL;
n->hasoids = $10;
n->oncommit = $11;
TableElementList:
TableElement
{
- $$ = makeList1($1);
+ $$ = list_make1($1);
}
| TableElementList ',' TableElement
{
;
columnList:
- columnElem { $$ = makeList1($1); }
+ columnElem { $$ = list_make1($1); }
| columnList ',' columnElem { $$ = lappend($1, $3); }
;
;
CreateAsList:
- CreateAsElement { $$ = makeList1($1); }
+ CreateAsElement { $$ = list_make1($1); }
| CreateAsList ',' CreateAsElement { $$ = lappend($1, $3); }
;
*/
handler_name:
name
- { $$ = makeList1(makeString($1)); }
+ { $$ = list_make1(makeString($1)); }
| dotted_name { $$ = $1; }
;
;
TriggerFuncArgs:
- TriggerFuncArg { $$ = makeList1($1); }
+ TriggerFuncArg { $$ = list_make1($1); }
| TriggerFuncArgs ',' TriggerFuncArg { $$ = lappend($1, $3); }
| /*EMPTY*/ { $$ = NIL; }
;
{
CreateTrigStmt *n = makeNode(CreateTrigStmt);
n->trigname = $3;
- n->args = makeList1($6);
+ n->args = list_make1($6);
n->isconstraint = TRUE;
n->deferrable = ($8 & 1) != 0;
n->initdeferred = ($8 & 2) != 0;
RangeVar *r = makeNode(RangeVar);
/* can't use qualified_name, sigh */
- switch (length($3))
+ switch (list_length($3))
{
case 1:
r->catalogname = NULL;
definition: '(' def_list ')' { $$ = $2; }
;
-def_list: def_elem { $$ = makeList1($1); }
+def_list: def_elem { $$ = list_make1($1); }
| def_list ',' def_elem { $$ = lappend($1, $3); }
;
;
opclass_item_list:
- opclass_item { $$ = makeList1($1); }
+ opclass_item { $$ = list_make1($1); }
| opclass_item_list ',' opclass_item { $$ = lappend($1, $3); }
;
;
any_name_list:
- any_name { $$ = makeList1($1); }
+ any_name { $$ = list_make1($1); }
| any_name_list ',' any_name { $$ = lappend($1, $3); }
;
-any_name: ColId { $$ = makeList1(makeString($1)); }
+any_name: ColId { $$ = list_make1(makeString($1)); }
| dotted_name { $$ = $1; }
;
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_AGGREGATE;
n->objname = $4;
- n->objargs = makeList1($6);
+ n->objargs = list_make1($6);
n->comment = $9;
$$ = (Node *) n;
}
/* Obsolete syntax supported for awhile for compatibility */
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_RULE;
- n->objname = makeList1(makeString($4));
+ n->objname = list_make1(makeString($4));
n->objargs = NIL;
n->comment = $6;
$$ = (Node *) n;
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_OPCLASS;
n->objname = $5;
- n->objargs = makeList1(makeString($7));
+ n->objargs = list_make1(makeString($7));
n->comment = $9;
$$ = (Node *) n;
}
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_LARGEOBJECT;
- n->objname = makeList1($5);
+ n->objname = list_make1($5);
n->objargs = NIL;
n->comment = $7;
$$ = (Node *) n;
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_CAST;
- n->objname = makeList1($5);
- n->objargs = makeList1($7);
+ n->objname = list_make1($5);
+ n->objargs = list_make1($7);
n->comment = $10;
$$ = (Node *) n;
}
/* either ALL [PRIVILEGES] or a list of individual privileges */
privileges: privilege_list { $$ = $1; }
- | ALL { $$ = makeListi1(ACL_ALL_RIGHTS); }
- | ALL PRIVILEGES { $$ = makeListi1(ACL_ALL_RIGHTS); }
+ | ALL { $$ = list_make1_int(ACL_ALL_RIGHTS); }
+ | ALL PRIVILEGES { $$ = list_make1_int(ACL_ALL_RIGHTS); }
;
privilege_list:
- privilege { $$ = makeListi1($1); }
- | privilege_list ',' privilege { $$ = lappendi($1, $3); }
+ privilege { $$ = list_make1_int($1); }
+ | privilege_list ',' privilege { $$ = lappend_int($1, $3); }
;
/* Not all of these privilege types apply to all objects, but that
grantee_list:
- grantee { $$ = makeList1($1); }
+ grantee { $$ = list_make1($1); }
| grantee_list ',' grantee { $$ = lappend($1, $3); }
;
function_with_argtypes_list:
- function_with_argtypes { $$ = makeList1($1); }
+ function_with_argtypes { $$ = list_make1($1); }
| function_with_argtypes_list ',' function_with_argtypes
{ $$ = lappend($1, $3); }
;
| /*EMPTY*/ { $$ = DEFAULT_INDEX_TYPE; }
;
-index_params: index_elem { $$ = makeList1($1); }
+index_params: index_elem { $$ = list_make1($1); }
| index_params ',' index_elem { $$ = lappend($1, $3); }
;
;
func_args_list:
- func_arg { $$ = makeList1($1); }
+ func_arg { $$ = list_make1($1); }
| func_args_list ',' func_arg { $$ = lappend($1, $3); }
;
createfunc_opt_list:
/* Must be at least one to prevent conflict */
- createfunc_opt_item { $$ = makeList1($1); }
+ createfunc_opt_item { $$ = list_make1($1); }
| createfunc_opt_list createfunc_opt_item { $$ = lappend($1, $2); }
;
}
;
-func_as: Sconst { $$ = makeList1(makeString($1)); }
+func_as: Sconst { $$ = list_make1(makeString($1)); }
| Sconst ',' Sconst
{
- $$ = makeList2(makeString($1), makeString($3));
+ $$ = list_make2(makeString($1), makeString($3));
}
;
errhint("Use NONE to denote the missing argument of a unary operator.")));
}
| Typename ',' Typename
- { $$ = makeList2($1, $3); }
+ { $$ = list_make2($1, $3); }
| NONE ',' Typename /* left unary */
- { $$ = makeList2(NULL, $3); }
+ { $$ = list_make2(NULL, $3); }
| Typename ',' NONE /* right unary */
- { $$ = makeList2($1, NULL); }
+ { $$ = list_make2($1, NULL); }
;
any_operator:
all_Op
- { $$ = makeList1(makeString($1)); }
+ { $$ = list_make1(makeString($1)); }
| ColId '.' any_operator
{ $$ = lcons(makeString($1), $3); }
;
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_AGGREGATE;
n->object = $3;
- n->objarg = makeList1($5);
+ n->objarg = list_make1($5);
n->newname = $9;
$$ = (Node *)n;
}
RuleActionList:
NOTHING { $$ = NIL; }
- | RuleActionStmt { $$ = makeList1($1); }
+ | RuleActionStmt { $$ = list_make1($1); }
| '(' RuleActionMulti ')' { $$ = $2; }
;
}
| RuleActionStmtOrEmpty
{ if ($1 != NULL)
- $$ = makeList1($1);
+ $$ = list_make1($1);
else
$$ = NIL;
}
transaction_mode_list:
ISOLATION LEVEL iso_level
- { $$ = makeList1(makeDefElem("transaction_isolation",
- makeStringConst($3, NULL))); }
+ { $$ = list_make1(makeDefElem("transaction_isolation",
+ makeStringConst($3, NULL))); }
| transaction_access_mode
- { $$ = makeList1(makeDefElem("transaction_read_only",
- makeIntConst($1))); }
+ { $$ = list_make1(makeDefElem("transaction_read_only",
+ makeIntConst($1))); }
| ISOLATION LEVEL iso_level transaction_access_mode
{
- $$ = makeList2(makeDefElem("transaction_isolation",
- makeStringConst($3, NULL)),
- makeDefElem("transaction_read_only",
- makeIntConst($4)));
+ $$ = list_make2(makeDefElem("transaction_isolation",
+ makeStringConst($3, NULL)),
+ makeDefElem("transaction_read_only",
+ makeIntConst($4)));
}
| transaction_access_mode ISOLATION LEVEL iso_level
{
- $$ = makeList2(makeDefElem("transaction_read_only",
- makeIntConst($1)),
- makeDefElem("transaction_isolation",
- makeStringConst($4, NULL)));
+ $$ = list_make2(makeDefElem("transaction_read_only",
+ makeIntConst($1)),
+ makeDefElem("transaction_isolation",
+ makeStringConst($4, NULL)));
}
;
| /* EMPTY */ { $$ = NIL; }
;
-prep_type_list: Typename { $$ = makeList1($1); }
+prep_type_list: Typename { $$ = list_make1($1); }
| prep_type_list ',' Typename
{ $$ = lappend($1, $3); }
;
;
insert_column_list:
- insert_column_item { $$ = makeList1($1); }
+ insert_column_item { $$ = list_make1($1); }
| insert_column_list ',' insert_column_item
{ $$ = lappend($1, $3); }
;
| select_clause opt_sort_clause for_update_clause opt_select_limit
{
insertSelectOptions((SelectStmt *) $1, $2, $3,
- nth(0, $4), nth(1, $4));
+ list_nth($4, 0), list_nth($4, 1));
$$ = $1;
}
| select_clause opt_sort_clause select_limit opt_for_update_clause
{
insertSelectOptions((SelectStmt *) $1, $2, $4,
- nth(0, $3), nth(1, $3));
+ list_nth($3, 0), list_nth($3, 1));
$$ = $1;
}
;
* should be placed in the DISTINCT list during parsetree analysis.
*/
opt_distinct:
- DISTINCT { $$ = makeList1(NIL); }
+ DISTINCT { $$ = list_make1(NIL); }
| DISTINCT ON '(' expr_list ')' { $$ = $4; }
| ALL { $$ = NIL; }
| /*EMPTY*/ { $$ = NIL; }
;
sortby_list:
- sortby { $$ = makeList1($1); }
+ sortby { $$ = list_make1($1); }
| sortby_list ',' sortby { $$ = lappend($1, $3); }
;
select_limit:
LIMIT select_limit_value OFFSET select_offset_value
- { $$ = makeList2($4, $2); }
+ { $$ = list_make2($4, $2); }
| OFFSET select_offset_value LIMIT select_limit_value
- { $$ = makeList2($2, $4); }
+ { $$ = list_make2($2, $4); }
| LIMIT select_limit_value
- { $$ = makeList2(NULL, $2); }
+ { $$ = list_make2(NULL, $2); }
| OFFSET select_offset_value
- { $$ = makeList2($2, NULL); }
+ { $$ = list_make2($2, NULL); }
| LIMIT select_limit_value ',' select_offset_value
{
/* Disabled because it was too confusing, bjm 2002-02-18 */
opt_select_limit:
select_limit { $$ = $1; }
| /* EMPTY */
- { $$ = makeList2(NULL,NULL); }
+ { $$ = list_make2(NULL,NULL); }
;
select_limit_value:
update_list:
OF name_list { $$ = $2; }
- | /* EMPTY */ { $$ = makeList1(NULL); }
+ | /* EMPTY */ { $$ = list_make1(NULL); }
;
/*****************************************************************************
;
from_list:
- table_ref { $$ = makeList1($1); }
+ table_ref { $$ = list_make1($1); }
| from_list ',' table_ref { $$ = lappend($1, $3); }
;
TableFuncElementList:
TableFuncElement
{
- $$ = makeList1($1);
+ $$ = list_make1($1);
}
| TableFuncElementList ',' TableFuncElement
{
{
/* SQL99's redundant syntax */
$$ = $1;
- $$->arrayBounds = makeList1(makeInteger($4));
+ $$->arrayBounds = list_make1(makeInteger($4));
}
| SETOF SimpleTypename ARRAY '[' Iconst ']'
{
/* SQL99's redundant syntax */
$$ = $2;
- $$->arrayBounds = makeList1(makeInteger($5));
+ $$->arrayBounds = list_make1(makeInteger($5));
$$->setof = TRUE;
}
;
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("timezone");
- n->args = makeList2($5, $1);
+ n->args = list_make2($5, $1);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) n;
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("like_escape");
- n->args = makeList2($3, $5);
+ n->args = list_make2($3, $5);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~", $1, (Node *) n);
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("like_escape");
- n->args = makeList2($4, $6);
+ n->args = list_make2($4, $6);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~", $1, (Node *) n);
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("like_escape");
- n->args = makeList2($3, $5);
+ n->args = list_make2($3, $5);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~*", $1, (Node *) n);
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("like_escape");
- n->args = makeList2($4, $6);
+ n->args = list_make2($4, $6);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~*", $1, (Node *) n);
FuncCall *n = makeNode(FuncCall);
c->val.type = T_Null;
n->funcname = SystemFuncName("similar_escape");
- n->args = makeList2($4, (Node *) c);
+ n->args = list_make2($4, (Node *) c);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~", $1, (Node *) n);
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("similar_escape");
- n->args = makeList2($4, $6);
+ n->args = list_make2($4, $6);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~", $1, (Node *) n);
FuncCall *n = makeNode(FuncCall);
c->val.type = T_Null;
n->funcname = SystemFuncName("similar_escape");
- n->args = makeList2($5, (Node *) c);
+ n->args = list_make2($5, (Node *) c);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~", $1, (Node *) n);
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("similar_escape");
- n->args = makeList2($5, $7);
+ n->args = list_make2($5, $7);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~", $1, (Node *) n);
if (IsA($1, RowExpr))
n->lefthand = ((RowExpr *) $1)->args;
else
- n->lefthand = makeList1($1);
- n->operName = makeList1(makeString("="));
+ n->lefthand = list_make1($1);
+ n->operName = list_make1(makeString("="));
$$ = (Node *)n;
}
else
if (IsA($1, RowExpr))
n->lefthand = ((RowExpr *) $1)->args;
else
- n->lefthand = makeList1($1);
- n->operName = makeList1(makeString("="));
+ n->lefthand = list_make1($1);
+ n->operName = list_make1(makeString("="));
/* Stick a NOT on top */
$$ = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL, (Node *) n);
}
if (IsA($1, RowExpr))
n->lefthand = ((RowExpr *) $1)->args;
else
- n->lefthand = makeList1($1);
+ n->lefthand = list_make1($1);
n->operName = $2;
n->subselect = $4;
$$ = (Node *)n;
star->val.type = T_Integer;
star->val.val.ival = 1;
n->funcname = $1;
- n->args = makeList1(star);
+ n->args = list_make1(star);
n->agg_star = TRUE;
n->agg_distinct = FALSE;
$$ = (Node *)n;
* at the moment they result in the same thing.
*/
n->funcname = SystemFuncName(((Value *)llast($5->names))->val.str);
- n->args = makeList1($3);
+ n->args = list_make1($3);
$$ = (Node *)n;
}
| TRIM '(' BOTH trim_list ')'
c->val.val.str = NameListToQuotedString($5);
n->funcname = SystemFuncName("convert_using");
- n->args = makeList2($3, c);
+ n->args = list_make2($3, c);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *)n;
;
qual_Op: Op
- { $$ = makeList1(makeString($1)); }
+ { $$ = list_make1(makeString($1)); }
| OPERATOR '(' any_operator ')'
{ $$ = $3; }
;
qual_all_Op:
all_Op
- { $$ = makeList1(makeString($1)); }
+ { $$ = list_make1(makeString($1)); }
| OPERATOR '(' any_operator ')'
{ $$ = $3; }
;
subquery_Op:
all_Op
- { $$ = makeList1(makeString($1)); }
+ { $$ = list_make1(makeString($1)); }
| OPERATOR '(' any_operator ')'
{ $$ = $3; }
| LIKE
- { $$ = makeList1(makeString("~~")); }
+ { $$ = list_make1(makeString("~~")); }
| NOT LIKE
- { $$ = makeList1(makeString("!~~")); }
+ { $$ = list_make1(makeString("!~~")); }
| ILIKE
- { $$ = makeList1(makeString("~~*")); }
+ { $$ = list_make1(makeString("~~*")); }
| NOT ILIKE
- { $$ = makeList1(makeString("!~~*")); }
+ { $$ = list_make1(makeString("!~~*")); }
/* cannot put SIMILAR TO here, because SIMILAR TO is a hack.
* the regular expression is preprocessed by a function (similar_escape),
* and the ~ operator for posix regular expressions is used.
A_Const *n = makeNode(A_Const);
n->val.type = T_String;
n->val.val.str = $1;
- $$ = makeList2((Node *) n, $3);
+ $$ = list_make2((Node *) n, $3);
}
| /*EMPTY*/ { $$ = NIL; }
;
}
| Typename
{
- $$ = makeList1($1);
+ $$ = list_make1($1);
}
;
array_expr_list: array_expr
- { $$ = makeList1($1); }
+ { $$ = list_make1($1); }
| array_expr_list ',' array_expr
{ $$ = lappend($1, $3); }
;
overlay_list:
a_expr overlay_placing substr_from substr_for
{
- $$ = makeList4($1, $2, $3, $4);
+ $$ = list_make4($1, $2, $3, $4);
}
| a_expr overlay_placing substr_from
{
- $$ = makeList3($1, $2, $3);
+ $$ = list_make3($1, $2, $3);
}
;
/* position_list uses b_expr not a_expr to avoid conflict with general IN */
position_list:
- b_expr IN_P b_expr { $$ = makeList2($3, $1); }
+ b_expr IN_P b_expr { $$ = list_make2($3, $1); }
| /*EMPTY*/ { $$ = NIL; }
;
substr_list:
a_expr substr_from substr_for
{
- $$ = makeList3($1, $2, $3);
+ $$ = list_make3($1, $2, $3);
}
| a_expr substr_for substr_from
{
- $$ = makeList3($1, $3, $2);
+ $$ = list_make3($1, $3, $2);
}
| a_expr substr_from
{
- $$ = makeList2($1, $2);
+ $$ = list_make2($1, $2);
}
| a_expr substr_for
{
A_Const *n = makeNode(A_Const);
n->val.type = T_Integer;
n->val.val.ival = 1;
- $$ = makeList3($1, (Node *)n, $2);
+ $$ = list_make3($1, (Node *)n, $2);
}
| expr_list
{
when_clause_list:
/* There must be at least one */
- when_clause { $$ = makeList1($1); }
+ when_clause { $$ = list_make1($1); }
| when_clause_list when_clause { $$ = lappend($1, $2); }
;
columnref: relation_name opt_indirection
{
$$ = makeNode(ColumnRef);
- $$->fields = makeList1(makeString($1));
+ $$->fields = list_make1(makeString($1));
$$->indirection = $2;
}
| dotted_name opt_indirection
;
attrs: '.' attr_name
- { $$ = makeList1(makeString($2)); }
+ { $$ = list_make1(makeString($2)); }
| '.' '*'
- { $$ = makeList1(makeString("*")); }
+ { $$ = list_make1(makeString("*")); }
| '.' attr_name attrs
{ $$ = lcons(makeString($2), $3); }
;
/* Target lists as found in SELECT ... and INSERT VALUES ( ... ) */
target_list:
- target_el { $$ = makeList1($1); }
+ target_el { $$ = list_make1($1); }
| target_list ',' target_el { $$ = lappend($1, $3); }
;
| '*'
{
ColumnRef *n = makeNode(ColumnRef);
- n->fields = makeList1(makeString("*"));
+ n->fields = list_make1(makeString("*"));
n->indirection = NIL;
$$ = makeNode(ResTarget);
$$->name = NULL;
}
*/
update_target_list:
- update_target_el { $$ = makeList1($1); }
+ update_target_el { $$ = list_make1($1); }
| update_target_list ',' update_target_el { $$ = lappend($1,$3); }
;
;
insert_target_list:
- insert_target_el { $$ = makeList1($1); }
+ insert_target_el { $$ = list_make1($1); }
| insert_target_list ',' insert_target_el { $$ = lappend($1, $3); }
;
;
qualified_name_list:
- qualified_name { $$ = makeList1($1); }
+ qualified_name { $$ = list_make1($1); }
| qualified_name_list ',' qualified_name { $$ = lappend($1, $3); }
;
| dotted_name
{
$$ = makeNode(RangeVar);
- switch (length($1))
+ switch (list_length($1))
{
case 2:
$$->catalogname = NULL;
;
name_list: name
- { $$ = makeList1(makeString($1)); }
+ { $$ = list_make1(makeString($1)); }
| name_list ',' name
{ $$ = lappend($1, makeString($3)); }
;
file_name: Sconst { $$ = $1; };
func_name: function_name
- { $$ = makeList1(makeString($1)); }
+ { $$ = list_make1(makeString($1)); }
| dotted_name { $$ = $1; }
;
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("overlaps");
- if (length(largs) == 1)
+ if (list_length(largs) == 1)
largs = lappend(largs, largs);
- else if (length(largs) != 2)
+ else if (list_length(largs) != 2)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("wrong number of parameters on left side of OVERLAPS expression")));
- if (length(rargs) == 1)
+ if (list_length(rargs) == 1)
rargs = lappend(rargs, rargs);
- else if (length(rargs) != 2)
+ else if (list_length(rargs) != 2)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("wrong number of parameters on right side of OVERLAPS expression")));
- n->args = nconc(largs, rargs);
+ n->args = list_concat(largs, rargs);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
return n;
List *
SystemFuncName(char *name)
{
- return makeList2(makeString("pg_catalog"), makeString(name));
+ return list_make2(makeString("pg_catalog"), makeString(name));
}
/* SystemTypeName()
{
TypeName *n = makeNode(TypeName);
- n->names = makeList2(makeString("pg_catalog"), makeString(name));
+ n->names = list_make2(makeString("pg_catalog"), makeString(name));
n->typmod = -1;
return n;
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.62 2004/05/26 04:41:29 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.63 2004/05/30 23:40:34 neilc Exp $
*
*-------------------------------------------------------------------------
*/
/* Found an ungrouped local variable; generate error message */
Assert(var->varno > 0 &&
- (int) var->varno <= length(context->pstate->p_rtable));
+ (int) var->varno <= list_length(context->pstate->p_rtable));
rte = rt_fetch(var->varno, context->pstate->p_rtable);
attname = get_rte_attribute_name(rte, var->varattno);
if (context->sublevels_up == 0)
arg1->paramid = -1;
arg1->paramtype = agg_input_type;
- args = makeList2(arg0, arg1);
+ args = list_make2(arg0, arg1);
}
else
- args = makeList1(arg0);
+ args = list_make1(arg0);
*transfnexpr = (Expr *) makeFuncExpr(transfn_oid,
agg_state_type,
arg0->paramkind = PARAM_EXEC;
arg0->paramid = -1;
arg0->paramtype = agg_state_type;
- args = makeList1(arg0);
+ args = list_make1(arg0);
*finalfnexpr = (Expr *) makeFuncExpr(finalfn_oid,
agg_result_type,
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.130 2004/05/26 04:41:29 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.131 2004/05/30 23:40:34 neilc Exp $
*
*-------------------------------------------------------------------------
*/
pstate->p_target_rangetblentry = rte;
/* assume new rte is at end */
- rtindex = length(pstate->p_rtable);
+ rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(rtindex, pstate->p_rtable));
/*
List *new_colvars = NIL;
ListCell *lnames, *lvars;
- Assert(length(src_colnames) == length(src_colvars));
+ Assert(list_length(src_colnames) == list_length(src_colvars));
forboth(lnames, src_colnames, lvars, src_colvars)
{
* to be added.
*/
save_namespace = pstate->p_namespace;
- pstate->p_namespace = makeList2(j->larg, j->rarg);
+ pstate->p_namespace = list_make2(j->larg, j->rarg);
result = transformWhereClause(pstate, j->quals, "JOIN/ON");
clause_varnos = pull_varnos(result);
while ((varno = bms_first_member(clause_varnos)) >= 0)
{
- if (!intMember(varno, containedRels))
+ if (!list_member_int(containedRels, varno))
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
*/
rtr = makeNode(RangeTblRef);
/* assume new rte is at end */
- rtr->rtindex = length(pstate->p_rtable);
+ rtr->rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(rtr->rtindex, pstate->p_rtable));
return rtr;
* are probably impossible given restrictions of the grammar, but
* check 'em anyway.
*/
- if (length(parsetrees) != 1)
+ if (list_length(parsetrees) != 1)
elog(ERROR, "unexpected parse analysis result for subquery in FROM");
query = (Query *) linitial(parsetrees);
if (query == NULL || !IsA(query, Query))
*/
rtr = makeNode(RangeTblRef);
/* assume new rte is at end */
- rtr->rtindex = length(pstate->p_rtable);
+ rtr->rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(rtr->rtindex, pstate->p_rtable));
return rtr;
*/
rtr = makeNode(RangeTblRef);
/* assume new rte is at end */
- rtr->rtindex = length(pstate->p_rtable);
+ rtr->rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(rtr->rtindex, pstate->p_rtable));
return rtr;
RangeTblRef *rtr;
rtr = transformTableEntry(pstate, (RangeVar *) n);
- *containedRels = makeListi1(rtr->rtindex);
+ *containedRels = list_make1_int(rtr->rtindex);
return (Node *) rtr;
}
else if (IsA(n, RangeSubselect))
RangeTblRef *rtr;
rtr = transformRangeSubselect(pstate, (RangeSubselect *) n);
- *containedRels = makeListi1(rtr->rtindex);
+ *containedRels = list_make1_int(rtr->rtindex);
return (Node *) rtr;
}
else if (IsA(n, RangeFunction))
RangeTblRef *rtr;
rtr = transformRangeFunction(pstate, (RangeFunction *) n);
- *containedRels = makeListi1(rtr->rtindex);
+ *containedRels = list_make1_int(rtr->rtindex);
return (Node *) rtr;
}
else if (IsA(n, JoinExpr))
* Generate combined list of relation indexes for possible use by
* transformJoinOnClause below.
*/
- my_containedRels = nconc(l_containedRels, r_containedRels);
+ my_containedRels = list_concat(l_containedRels, r_containedRels);
/*
* Check for conflicting refnames in left and right subtrees. Must
errmsg("column \"%s\" specified in USING clause does not exist in right table",
u_colname)));
- l_colvar = nth(l_index, l_colvars);
+ l_colvar = list_nth(l_colvars, l_index);
l_usingvars = lappend(l_usingvars, l_colvar);
- r_colvar = nth(r_index, r_colvars);
+ r_colvar = list_nth(r_colvars, r_index);
r_usingvars = lappend(r_usingvars, r_colvar);
res_colnames = lappend(res_colnames, lfirst(ucol));
extractRemainingColumns(res_colnames,
r_colnames, r_colvars,
&r_colnames, &r_colvars);
- res_colnames = nconc(res_colnames, l_colnames);
- res_colvars = nconc(res_colvars, l_colvars);
- res_colnames = nconc(res_colnames, r_colnames);
- res_colvars = nconc(res_colvars, r_colvars);
+ res_colnames = list_concat(res_colnames, l_colnames);
+ res_colvars = list_concat(res_colvars, l_colvars);
+ res_colnames = list_concat(res_colnames, r_colnames);
+ res_colvars = list_concat(res_colvars, r_colvars);
/*
* Check alias (AS clause), if any.
{
if (j->alias->colnames != NIL)
{
- if (length(j->alias->colnames) > length(res_colnames))
+ if (list_length(j->alias->colnames) > list_length(res_colnames))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("column alias list for \"%s\" has too many entries",
true);
/* assume new rte is at end */
- j->rtindex = length(pstate->p_rtable);
+ j->rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(j->rtindex, pstate->p_rtable));
/*
* Include join RTE in returned containedRels list
*/
- *containedRels = lconsi(j->rtindex, my_containedRels);
+ *containedRels = lcons_int(j->rtindex, my_containedRels);
return (Node *) j;
}
outcoltypmod = l_colvar->vartypmod;
if (outcoltype != r_colvar->vartype)
{
- outcoltype = select_common_type(makeListo2(l_colvar->vartype,
- r_colvar->vartype),
+ outcoltype = select_common_type(list_make2_oid(l_colvar->vartype,
+ r_colvar->vartype),
"JOIN/USING");
outcoltypmod = -1; /* ie, unknown */
}
CoalesceExpr *c = makeNode(CoalesceExpr);
c->coalescetype = outcoltype;
- c->args = makeList2(l_node, r_node);
+ c->args = list_make2(l_node, r_node);
res_node = (Node *) c;
break;
}
*----------
*/
if (IsA(node, ColumnRef) &&
- length(((ColumnRef *) node)->fields) == 1 &&
+ list_length(((ColumnRef *) node)->fields) == 1 &&
((ColumnRef *) node)->indirection == NIL)
{
char *name = strVal(linitial(((ColumnRef *) node)->fields));
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.116 2004/05/26 04:41:30 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.117 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
Oid baseTypeId = getBaseType(targetTypeId);
result = (Node *) makeFuncExpr(funcId, baseTypeId,
- makeList1(node),
+ list_make1(node),
cformat);
/*
false,
true);
- args = makeList2(node, cons);
+ args = list_make2(node, cons);
if (nargs == 3)
{
rte = GetRTEByRangeTablePosn(pstate,
((Var *) node)->varno,
((Var *) node)->varlevelsup);
- nfields = length(rte->eref->colnames);
+ nfields = list_length(rte->eref->colnames);
for (nf = 1; nf <= nfields; nf++)
{
Oid vartype;
format_type_be(targetTypeId))));
tupdesc = lookup_rowtype_tupdesc(targetTypeId, -1);
- if (length(args) != tupdesc->natts)
+ if (list_length(args) != tupdesc->natts)
ereport(ERROR,
(errcode(ERRCODE_CANNOT_COERCE),
errmsg("cannot cast type %s to %s",
for_each_cell(type_item, lnext(list_head(typeids)))
{
- Oid ntype = getBaseType(lfirsto(type_item));
+ Oid ntype = getBaseType(lfirst_oid(type_item));
/* move on to next one if no new information... */
if ((ntype != InvalidOid) && (ntype != UNKNOWNOID) && (ntype != ptype))
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.171 2004/05/26 04:41:30 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.172 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
foreach(fields, pref->fields)
{
result = ParseFuncOrColumn(pstate,
- makeList1(lfirst(fields)),
- makeList1(result),
+ list_make1(lfirst(fields)),
+ list_make1(result),
false, false, true);
}
/* handle subscripts, if any */
foreach(fields, efs->fields)
{
result = ParseFuncOrColumn(pstate,
- makeList1(lfirst(fields)),
- makeList1(result),
+ list_make1(lfirst(fields)),
+ list_make1(result),
false, false, true);
}
/* handle subscripts, if any */
* into IS NULL exprs.
*/
if (Transform_null_equals &&
- length(a->name) == 1 &&
+ list_length(a->name) == 1 &&
strcmp(strVal(linitial(a->name)), "=") == 0 &&
(exprIsNullConstant(lexpr) ||
exprIsNullConstant(rexpr)))
rexpr = coerce_to_boolean(pstate, rexpr, "AND");
result = (Node *) makeBoolExpr(AND_EXPR,
- makeList2(lexpr,
- rexpr));
+ list_make2(lexpr,
+ rexpr));
}
break;
case AEXPR_OR:
rexpr = coerce_to_boolean(pstate, rexpr, "OR");
result = (Node *) makeBoolExpr(OR_EXPR,
- makeList2(lexpr,
- rexpr));
+ list_make2(lexpr,
+ rexpr));
}
break;
case AEXPR_NOT:
rexpr = coerce_to_boolean(pstate, rexpr, "NOT");
result = (Node *) makeBoolExpr(NOT_EXPR,
- makeList1(rexpr));
+ list_make1(rexpr));
}
break;
case AEXPR_OP_ANY:
* XXX: repeated lappend() would no longer result in
* O(n^2) behavior; worth reconsidering this design?
*/
- targs = listCopy(fn->args);
+ targs = list_copy(fn->args);
foreach(args, targs)
{
lfirst(args) = transformExpr(pstate,
}
pstate->p_hasSubLinks = true;
qtrees = parse_sub_analyze(sublink->subselect, pstate);
- if (length(qtrees) != 1)
+ if (list_length(qtrees) != 1)
elog(ERROR, "bad query in sub-select");
qtree = (Query *) linitial(qtrees);
if (qtree->commandType != CMD_SELECT ||
/* ALL, ANY, or MULTIEXPR: generate operator list */
List *left_list = sublink->lefthand;
List *right_list = qtree->targetList;
- int row_length = length(left_list);
+ int row_length = list_length(left_list);
bool needNot = false;
List *op = sublink->operName;
char *opname = strVal(llast(op));
* pre-7.4 Postgres.
*/
if (sublink->subLinkType == ALL_SUBLINK &&
- length(op) == 1 && strcmp(opname, "<>") == 0)
+ list_length(op) == 1 && strcmp(opname, "<>") == 0)
{
sublink->subLinkType = ANY_SUBLINK;
opname = pstrdup("=");
- op = makeList1(makeString(opname));
+ op = list_make1(makeString(opname));
sublink->operName = op;
needNot = true;
}
opname),
errhint("The operator of a quantified predicate subquery must return type boolean.")));
- sublink->operOids = lappendo(sublink->operOids,
- oprid(optup));
+ sublink->operOids = lappend_oid(sublink->operOids,
+ oprid(optup));
ReleaseSysCache(optup);
}
{
expr = coerce_to_boolean(pstate, expr, "NOT");
expr = (Node *) makeBoolExpr(NOT_EXPR,
- makeList1(expr));
+ list_make1(expr));
}
}
result = (Node *) expr;
neww->result = (Expr *) transformExpr(pstate, warg);
newargs = lappend(newargs, neww);
- typeids = lappendo(typeids, exprType((Node *) neww->result));
+ typeids = lappend_oid(typeids, exprType((Node *) neww->result));
}
newc->args = newargs;
* code worked before, but it seems a little bogus to me
* --- tgl
*/
- typeids = lconso(exprType((Node *) newc->defresult), typeids);
+ typeids = lcons_oid(exprType((Node *) newc->defresult), typeids);
ptype = select_common_type(typeids, "CASE");
Assert(OidIsValid(ptype));
newe = transformExpr(pstate, e);
newelems = lappend(newelems, newe);
- typeids = lappendo(typeids, exprType(newe));
+ typeids = lappend_oid(typeids, exprType(newe));
}
/* Select a common type for the elements */
newe = transformExpr(pstate, e);
newargs = lappend(newargs, newe);
- typeids = lappendo(typeids, exprType(newe));
+ typeids = lappend_oid(typeids, exprType(newe));
}
newc->coalescetype = select_common_type(typeids, "COALESCE");
static Node *
transformColumnRef(ParseState *pstate, ColumnRef *cref)
{
- int numnames = length(cref->fields);
+ int numnames = list_length(cref->fields);
Node *node;
int levels_up;
*/
node = transformWholeRowRef(pstate, NULL, name1);
node = ParseFuncOrColumn(pstate,
- makeList1(makeString(name2)),
- makeList1(node),
+ list_make1(makeString(name2)),
+ list_make1(node),
false, false, true);
}
break;
/* Try it as a function call */
node = transformWholeRowRef(pstate, name1, name2);
node = ParseFuncOrColumn(pstate,
- makeList1(makeString(name3)),
- makeList1(node),
+ list_make1(makeString(name3)),
+ list_make1(node),
false, false, true);
}
break;
/* Try it as a function call */
node = transformWholeRowRef(pstate, name2, name3);
node = ParseFuncOrColumn(pstate,
- makeList1(makeString(name4)),
- makeList1(node),
+ list_make1(makeString(name4)),
+ list_make1(node),
false, false, true);
}
break;
* second argument being an int4 constant, it can't have been created
* from a length coercion (it must be a type coercion, instead).
*/
- nargs = length(func->args);
+ nargs = list_length(func->args);
if (nargs < 2 || nargs > 3)
return false;
largs = lrow->args;
rargs = rrow->args;
- if (length(largs) != length(rargs))
+ if (list_length(largs) != list_length(rargs))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("unequal number of entries in row expression")));
result = cmp;
else
result = (Node *) makeBoolExpr(boolop,
- makeList2(result, cmp));
+ list_make2(result, cmp));
}
if (result == NULL)
largs = lrow->args;
rargs = rrow->args;
- if (length(largs) != length(rargs))
+ if (list_length(largs) != list_length(rargs))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("unequal number of entries in row expression")));
result = cmp;
else
result = (Node *) makeBoolExpr(OR_EXPR,
- makeList2(result, cmp));
+ list_make2(result, cmp));
}
if (result == NULL)
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.169 2004/05/26 04:41:30 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.170 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
Oid funcid;
ListCell *l;
Node *first_arg = NULL;
- int nargs = length(fargs);
+ int nargs = list_length(fargs);
int argn;
Oid actual_arg_types[FUNC_MAX_ARGS];
Oid *declared_arg_types;
* then the "function call" could be a projection. We also check that
* there wasn't any aggregate decoration.
*/
- if (nargs == 1 && !agg_star && !agg_distinct && length(funcname) == 1)
+ if (nargs == 1 && !agg_star && !agg_distinct && list_length(funcname) == 1)
{
Oid argtype = exprType(first_arg);
if (is_column)
{
Assert(nargs == 1);
- Assert(length(funcname) == 1);
+ Assert(list_length(funcname) == 1);
unknown_attribute(pstate, first_arg, strVal(linitial(funcname)));
}
else
*supervec = NULL;
- freeList(visited);
- freeList(queue);
+ list_free(visited);
+ list_free(queue);
return nvisited;
}
ListCell *args_item;
MemSet(argoids, 0, FUNC_MAX_ARGS * sizeof(Oid));
- argcount = length(argtypes);
+ argcount = list_length(argtypes);
if (argcount > FUNC_MAX_ARGS)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.77 2003/11/29 19:51:52 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.78 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
tup = oper(opname, ltypeId, rtypeId, false);
opform = (Form_pg_operator) GETSTRUCT(tup);
- args = makeList2(ltree, rtree);
+ args = list_make2(ltree, rtree);
actual_arg_types[0] = ltypeId;
actual_arg_types[1] = rtypeId;
declared_arg_types[0] = opform->oprleft;
if (rtree == NULL)
{
/* right operator */
- args = makeList1(ltree);
+ args = list_make1(ltree);
actual_arg_types[0] = ltypeId;
declared_arg_types[0] = opform->oprleft;
nargs = 1;
else if (ltree == NULL)
{
/* left operator */
- args = makeList1(rtree);
+ args = list_make1(rtree);
actual_arg_types[0] = rtypeId;
declared_arg_types[0] = opform->oprright;
nargs = 1;
else
{
/* otherwise, binary operator */
- args = makeList2(ltree, rtree);
+ args = list_make2(ltree, rtree);
actual_arg_types[0] = ltypeId;
actual_arg_types[1] = rtypeId;
declared_arg_types[0] = opform->oprleft;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.95 2004/05/26 04:41:30 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.96 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
pstate = pstate->parentParseState;
Assert(pstate != NULL);
}
- Assert(varno > 0 && varno <= length(pstate->p_rtable));
+ Assert(varno > 0 && varno <= list_length(pstate->p_rtable));
return rt_fetch(varno, pstate->p_rtable);
}
rte->relid = RelationGetRelid(rel);
eref = alias ? (Alias *) copyObject(alias) : makeAlias(refname, NIL);
- numaliases = length(eref->colnames);
+ numaliases = list_length(eref->colnames);
/*
* Since the rel is open anyway, let's check that the number of column
rte->relid = relid;
eref = (Alias *) copyObject(alias);
- numaliases = length(eref->colnames);
+ numaliases = list_length(eref->colnames);
/*
* Since the rel is open anyway, let's check that the number of column
rte->alias = alias;
eref = copyObject(alias);
- numaliases = length(eref->colnames);
+ numaliases = list_length(eref->colnames);
/* fill in any unspecified alias columns */
varattno = 0;
eref = alias ? (Alias *) copyObject(alias) : makeAlias(funcname, NIL);
rte->eref = eref;
- numaliases = length(eref->colnames);
+ numaliases = list_length(eref->colnames);
/*
* Now determine if the function returns a simple or composite type,
errmsg("too many column aliases specified for function %s",
funcname)));
if (numaliases == 0)
- eref->colnames = makeList1(makeString(eref->aliasname));
+ eref->colnames = list_make1(makeString(eref->aliasname));
}
else if (functyptype == 'p' && funcrettype == RECORDOID)
{
rte->alias = alias;
eref = alias ? (Alias *) copyObject(alias) : makeAlias("unnamed_join", NIL);
- numaliases = length(eref->colnames);
+ numaliases = list_length(eref->colnames);
/* fill in any unspecified alias columns */
- if (numaliases < length(colnames))
- eref->colnames = nconc(eref->colnames,
- list_copy_tail(colnames, numaliases));
+ if (numaliases < list_length(colnames))
+ eref->colnames = list_concat(eref->colnames,
+ list_copy_tail(colnames, numaliases));
rte->eref = eref;
rel = heap_open(rte->relid, AccessShareLock);
maxattrs = RelationGetNumberOfAttributes(rel);
- numaliases = length(rte->eref->colnames);
+ numaliases = list_length(rte->eref->colnames);
for (varattno = 0; varattno < maxattrs; varattno++)
{
char *label;
if (varattno < numaliases)
- label = strVal(nth(varattno, rte->eref->colnames));
+ label = strVal(list_nth(rte->eref->colnames, varattno));
else
label = NameStr(attr->attname);
*colnames = lappend(*colnames, makeString(pstrdup(label)));
rel = relation_open(funcrelid, AccessShareLock);
maxattrs = RelationGetNumberOfAttributes(rel);
- numaliases = length(rte->eref->colnames);
+ numaliases = list_length(rte->eref->colnames);
for (varattno = 0; varattno < maxattrs; varattno++)
{
char *label;
if (varattno < numaliases)
- label = strVal(nth(varattno, rte->eref->colnames));
+ label = strVal(list_nth(rte->eref->colnames, varattno));
else
label = NameStr(attr->attname);
*colnames = lappend(*colnames, makeString(pstrdup(label)));
ListCell *colname;
ListCell *aliasvar;
- Assert(length(rte->eref->colnames) == length(rte->joinaliasvars));
+ Assert(list_length(rte->eref->colnames) == list_length(rte->joinaliasvars));
varattno = 0;
forboth (colname, rte->eref->colnames, aliasvar, rte->joinaliasvars)
* If there is a user-written column alias, use it.
*/
if (rte->alias &&
- attnum > 0 && attnum <= length(rte->alias->colnames))
- return strVal(nth(attnum - 1, rte->alias->colnames));
+ attnum > 0 && attnum <= list_length(rte->alias->colnames))
+ return strVal(list_nth(rte->alias->colnames, attnum - 1));
/*
* If the RTE is a relation, go to the system catalogs not the
* Otherwise use the column name from eref. There should always be
* one.
*/
- if (attnum > 0 && attnum <= length(rte->eref->colnames))
- return strVal(nth(attnum - 1, rte->eref->colnames));
+ if (attnum > 0 && attnum <= list_length(rte->eref->colnames))
+ return strVal(list_nth(rte->eref->colnames, attnum - 1));
/* else caller gave us a bogus attnum */
elog(ERROR, "invalid attnum %d for rangetable entry %s",
}
else if (functyptype == 'p' && funcrettype == RECORDOID)
{
- ColumnDef *colDef = nth(attnum - 1, coldeflist);
+ ColumnDef *colDef = list_nth(coldeflist, attnum - 1);
*vartype = typenameTypeId(colDef->typename);
*vartypmod = -1;
*/
Node *aliasvar;
- Assert(attnum > 0 && attnum <= length(rte->joinaliasvars));
- aliasvar = (Node *) nth(attnum - 1, rte->joinaliasvars);
+ Assert(attnum > 0 && attnum <= list_length(rte->joinaliasvars));
+ aliasvar = (Node *) list_nth(rte->joinaliasvars, attnum - 1);
*vartype = exprType(aliasvar);
*vartypmod = exprTypmod(aliasvar);
}
*
* Returns NULL if resno is not present in list.
*
- * Note: we need to search, rather than just indexing with nth(), because
- * not all tlists are sorted by resno.
+ * Note: we need to search, rather than just indexing with list_nth(),
+ * because not all tlists are sorted by resno.
*/
TargetEntry *
get_tle_by_resno(List *tlist, AttrNumber resno)
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.118 2004/05/26 04:41:30 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.119 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
if (strcmp(strVal(llast(fields)), "*") == 0)
{
- int numnames = length(fields);
+ int numnames = list_length(fields);
if (numnames == 1)
{
/* Join RTE --- recursively inspect the alias variable */
Var *aliasvar;
- Assert(attnum > 0 && attnum <= length(rte->joinaliasvars));
- aliasvar = (Var *) nth(attnum - 1, rte->joinaliasvars);
+ Assert(attnum > 0 && attnum <= list_length(rte->joinaliasvars));
+ aliasvar = (Var *) list_nth(rte->joinaliasvars, attnum - 1);
markTargetListOrigin(pstate, res, aliasvar);
}
break;
col->indirection = NIL;
col->val = NULL;
cols = lappend(cols, col);
- *attrnos = lappendi(*attrnos, i + 1);
+ *attrnos = lappend_int(*attrnos, i + 1);
}
}
else
/* Lookup column name, ereport on failure */
attrno = attnameAttNum(pstate->p_target_relation, name, false);
/* Check for duplicates */
- if (intMember(attrno, *attrnos))
+ if (list_member_int(*attrnos, attrno))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_COLUMN),
errmsg("column \"%s\" specified more than once",
name)));
- *attrnos = lappendi(*attrnos, attrno);
+ *attrnos = lappend_int(*attrnos, attrno);
}
}
continue;
found_table = true;
- target = nconc(target, expandRelAttrs(pstate, rte));
+ target = list_concat(target, expandRelAttrs(pstate, rte));
}
/* Check for SELECT *; */
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.66 2004/05/26 04:41:30 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.67 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
AttrNumber attnum;
/* deconstruct the name list */
- switch (length(typename->names))
+ switch (list_length(typename->names))
{
case 1:
ereport(ERROR,
* Make sure we got back exactly what we expected and no more;
* paranoia is justified since the string might contain anything.
*/
- if (length(raw_parsetree_list) != 1)
+ if (list_length(raw_parsetree_list) != 1)
goto fail;
stmt = (SelectStmt *) linitial(raw_parsetree_list);
if (stmt == NULL ||
stmt->forUpdate != NIL ||
stmt->op != SETOP_NONE)
goto fail;
- if (length(stmt->targetList) != 1)
+ if (list_length(stmt->targetList) != 1)
goto fail;
restarget = (ResTarget *) linitial(stmt->targetList);
if (restarget == NULL ||
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/rewrite/rewriteDefine.c,v 1.95 2004/05/26 04:41:33 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/rewrite/rewriteDefine.c,v 1.96 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
/*
* So there cannot be INSTEAD NOTHING, ...
*/
- if (length(action) == 0)
+ if (list_length(action) == 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("INSTEAD NOTHING rules on SELECT are not implemented"),
/*
* ... there cannot be multiple actions, ...
*/
- if (length(action) > 1)
+ if (list_length(action) > 1)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("multiple actions for rules on SELECT are not implemented")));
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.137 2004/05/29 05:55:13 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.138 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
rule_qual = (Node *) copyObject(rule_qual);
current_varno = rt_index;
- rt_length = length(parsetree->rtable);
+ rt_length = list_length(parsetree->rtable);
new_varno = PRS2_NEW_VARNO + rt_length;
/*
* that rule action's rtable is separate and shares no substructure
* with the main rtable. Hence do a deep copy here.
*/
- sub_action->rtable = nconc((List *) copyObject(parsetree->rtable),
+ sub_action->rtable = list_concat((List *) copyObject(parsetree->rtable),
sub_action->rtable);
/*
errmsg("conditional UNION/INTERSECT/EXCEPT statements are not implemented")));
sub_action->jointree->fromlist =
- nconc(newjointree, sub_action->jointree->fromlist);
+ list_concat(newjointree, sub_action->jointree->fromlist);
}
}
if (IsA(rtr, RangeTblRef) &&
rtr->rtindex == rt_index)
{
- newjointree = lremove(rtr, newjointree);
- /* foreach is safe because we exit loop after lremove... */
+ newjointree = list_delete_ptr(newjointree, rtr);
+ /* foreach is safe because we exit loop after list_delete... */
break;
}
}
RangeTblEntry *rte,
*subrte;
- if (length(rule->actions) != 1)
+ if (list_length(rule->actions) != 1)
elog(ERROR, "expected just one rule action");
if (rule->qual != NULL)
elog(ERROR, "cannot handle qualified ON SELECT rule");
/*
* FOR UPDATE of view?
*/
- if (intMember(rt_index, parsetree->rowMarks))
+ if (list_member_int(parsetree->rowMarks, rt_index))
{
/*
* Remove the view from the list of rels that will actually be
* marked FOR UPDATE by the executor. It will still be access-
* checked for write access, though.
*/
- parsetree->rowMarks = lremovei(rt_index, parsetree->rowMarks);
+ parsetree->rowMarks = list_delete_int(parsetree->rowMarks, rt_index);
/*
* Set up the view's referenced tables as if FOR UPDATE.
if (rte->rtekind == RTE_RELATION)
{
- if (!intMember(rti, qry->rowMarks))
- qry->rowMarks = lappendi(qry->rowMarks, rti);
+ if (!list_member_int(qry->rowMarks, rti))
+ qry->rowMarks = lappend_int(qry->rowMarks, rti);
rte->requiredPerms |= ACL_SELECT_FOR_UPDATE;
}
else if (rte->rtekind == RTE_SUBQUERY)
* can get changed each time through...
*/
rt_index = 0;
- while (rt_index < length(parsetree->rtable))
+ while (rt_index < list_length(parsetree->rtable))
{
RangeTblEntry *rte;
Relation rel;
*/
if (rt_index == parsetree->resultRelation)
lockmode = NoLock;
- else if (intMember(rt_index, parsetree->rowMarks))
+ else if (list_member_int(parsetree->rowMarks, rt_index))
lockmode = RowShareLock;
else
lockmode = AccessShareLock;
{
ListCell *l;
- if (oidMember(RelationGetRelid(rel), activeRIRs))
+ if (list_member_oid(activeRIRs, RelationGetRelid(rel)))
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("infinite recursion detected in rules for relation \"%s\"",
RelationGetRelationName(rel))));
- activeRIRs = lconso(RelationGetRelid(rel), activeRIRs);
+ activeRIRs = lcons_oid(RelationGetRelid(rel), activeRIRs);
foreach(l, locks)
{
List *newstuff;
newstuff = RewriteQuery(pt, rewrite_events);
- rewritten = nconc(rewritten, newstuff);
+ rewritten = list_concat(rewritten, newstuff);
}
}
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.83 2004/05/26 04:41:33 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.84 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
if (qry->resultRelation)
qry->resultRelation += offset;
foreach(l, qry->rowMarks)
- lfirsti(l) += offset;
+ lfirst_int(l) += offset;
}
query_tree_walker(qry, OffsetVarNodes_walker,
(void *) &context, 0);
qry->resultRelation = new_index;
foreach(l, qry->rowMarks)
{
- if (lfirsti(l) == rt_index)
- lfirsti(l) = new_index;
+ if (lfirst_int(l) == rt_index)
+ lfirst_int(l) = new_index;
}
}
query_tree_walker(qry, ChangeVarNodes_walker,
* query. If they're not there, it must be an INSERT/SELECT in which
* they've been pushed down to the SELECT.
*/
- if (length(parsetree->rtable) >= 2 &&
+ if (list_length(parsetree->rtable) >= 2 &&
strcmp(rt_fetch(PRS2_OLD_VARNO, parsetree->rtable)->eref->aliasname,
"*OLD*") == 0 &&
strcmp(rt_fetch(PRS2_NEW_VARNO, parsetree->rtable)->eref->aliasname,
"*NEW*") == 0)
return parsetree;
Assert(parsetree->jointree && IsA(parsetree->jointree, FromExpr));
- if (length(parsetree->jointree->fromlist) != 1)
+ if (list_length(parsetree->jointree->fromlist) != 1)
elog(ERROR, "expected to find SELECT subquery");
rtr = (RangeTblRef *) linitial(parsetree->jointree->fromlist);
Assert(IsA(rtr, RangeTblRef));
if (!(selectquery && IsA(selectquery, Query) &&
selectquery->commandType == CMD_SELECT))
elog(ERROR, "expected to find SELECT subquery");
- if (length(selectquery->rtable) >= 2 &&
+ if (list_length(selectquery->rtable) >= 2 &&
strcmp(rt_fetch(PRS2_OLD_VARNO, selectquery->rtable)->eref->aliasname,
"*OLD*") == 0 &&
strcmp(rt_fetch(PRS2_NEW_VARNO, selectquery->rtable)->eref->aliasname,
RangeTblEntry *rte = context->target_rte;
RowExpr *rowexpr;
List *fields = NIL;
- AttrNumber nfields = length(rte->eref->colnames);
+ AttrNumber nfields = list_length(rte->eref->colnames);
AttrNumber nf;
for (nf = 1; nf <= nfields; nf++)
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/name.c,v 1.51 2004/05/26 04:41:37 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/name.c,v 1.52 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
/* +1 here is just to avoid palloc(0) error */
- names = (Datum *) palloc((length(search_path) + 1) * sizeof(Datum));
+ names = (Datum *) palloc((list_length(search_path) + 1) * sizeof(Datum));
i = 0;
foreach(l, search_path)
{
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/not_in.c,v 1.38 2003/11/29 19:51:59 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/not_in.c,v 1.39 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
/* Parse the argument */
names = textToQualifiedNameList(relation_and_attr, "int4notin");
- nnames = length(names);
+ nnames = list_length(names);
if (nnames < 2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_NAME),
errmsg("invalid name syntax"),
errhint("Must provide \"relationname.columnname\".")));
attribute = strVal(llast(names));
- names = ltruncate(nnames - 1, names);
+ names = list_truncate(names, nnames - 1);
relrv = makeRangeVarFromNameList(names);
/* Open the relation and get a relation descriptor */
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.88 2004/05/26 04:41:37 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.89 2004/05/30 23:40:36 neilc Exp $
*
*-------------------------------------------------------------------------
*/
* Would this proc be found (uniquely!) by regprocin? If not,
* qualify it.
*/
- clist = FuncnameGetCandidates(makeList1(makeString(proname)), -1);
+ clist = FuncnameGetCandidates(list_make1(makeString(proname)), -1);
if (clist != NULL && clist->next == NULL &&
clist->oid == proid)
nspname = NULL;
* Would this oper be found (uniquely!) by regoperin? If not,
* qualify it.
*/
- clist = OpernameGetCandidates(makeList1(makeString(oprname)),
+ clist = OpernameGetCandidates(list_make1(makeString(oprname)),
'\0');
if (clist != NULL && clist->next == NULL &&
clist->oid == oprid)
}
pfree(rawname);
- freeList(namelist);
+ list_free(namelist);
return result;
}
*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.68 2004/05/26 04:41:38 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.69 2004/05/30 23:40:36 neilc Exp $
*
* ----------
*/
{
HeapTuple tuple = SPI_tuptable->vals[0];
TupleDesc tupdesc = SPI_tuptable->tupdesc;
- int nkeys = length(fkconstraint->fk_attrs);
+ int nkeys = list_length(fkconstraint->fk_attrs);
int i;
RI_QueryKey qkey;
* back to source text
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.168 2004/05/26 19:30:12 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.169 2004/05/30 23:40:36 neilc Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
rte->inFromCl = true;
/* Build one-element rtable */
- dpns->rtable = makeList1(rte);
+ dpns->rtable = list_make1(rte);
dpns->outer_varno = dpns->inner_varno = 0;
dpns->outer_rte = dpns->inner_rte = NULL;
/* Return a one-deep namespace stack */
- return makeList1(dpns);
+ return list_make1(dpns);
}
/*
dpns->inner_rte = (RangeTblEntry *) innercontext;
/* Return a one-deep namespace stack */
- return makeList1(dpns);
+ return list_make1(dpns);
}
/*
RangeTblEntry *rte = makeNode(RangeTblEntry);
List *attrs = NIL;
int nattrs = 0;
- int rtablelength = length(rtable);
+ int rtablelength = list_length(rtable);
ListCell *tl;
char buf[32];
query = getInsertSelectQuery(query, NULL);
context.buf = buf;
- context.namespaces = makeList1(&dpns);
- context.varprefix = (length(query->rtable) != 1);
+ context.namespaces = list_make1(&dpns);
+ context.varprefix = (list_length(query->rtable) != 1);
context.prettyFlags = prettyFlags;
context.indentLevel = PRETTYINDENT_STD;
dpns.rtable = query->rtable;
appendStringInfo(buf, "INSTEAD ");
/* Finally the rules actions */
- if (length(actions) > 1)
+ if (list_length(actions) > 1)
{
ListCell *action;
Query *query;
}
appendStringInfo(buf, ");");
}
- else if (length(actions) == 0)
+ else if (list_length(actions) == 0)
{
appendStringInfo(buf, "NOTHING;");
}
if (ev_action != NULL)
actions = (List *) stringToNode(ev_action);
- if (length(actions) != 1)
+ if (list_length(actions) != 1)
{
appendStringInfo(buf, "Not a view");
return;
context.buf = buf;
context.namespaces = lcons(&dpns, list_copy(parentnamespace));
context.varprefix = (parentnamespace != NIL ||
- length(query->rtable) != 1);
+ list_length(query->rtable) != 1);
context.prettyFlags = prettyFlags;
context.indentLevel = startIndent;
var->varlevelsup);
/* Find the relevant RTE */
- if (var->varno >= 1 && var->varno <= length(dpns->rtable))
+ if (var->varno >= 1 && var->varno <= list_length(dpns->rtable))
rte = rt_fetch(var->varno, dpns->rtable);
else if (var->varno == dpns->outer_varno)
rte = dpns->outer_rte;
{
List *args = expr->args;
- if (length(args) == 2)
+ if (list_length(args) == 2)
{
/* binary operator */
Node *arg1 = (Node *) linitial(args);
char *sep;
/*
- * SQL99 allows "ROW" to be omitted when length(args) > 1,
+ * SQL99 allows "ROW" to be omitted when list_length(args) > 1,
* but for simplicity we always print it.
*/
appendStringInfo(buf, "ROW(");
if (!PRETTY_PAREN(context))
appendStringInfoChar(buf, '(');
- if (length(args) == 2)
+ if (list_length(args) == 2)
{
/* binary operator */
Node *arg1 = (Node *) linitial(args);
if (sublink->lefthand != NIL)
{
- need_paren = (length(sublink->lefthand) > 1);
+ need_paren = (list_length(sublink->lefthand) > 1);
if (need_paren)
appendStringInfoChar(buf, '(');
break;
case ANY_SUBLINK:
- if (length(sublink->operName) == 1 &&
+ if (list_length(sublink->operName) == 1 &&
strcmp(strVal(linitial(sublink->operName)), "=") == 0)
{
/* Represent = ANY as IN */
* resolve the correct function given the unqualified func name with
* the specified argtypes.
*/
- p_result = func_get_detail(makeList1(makeString(proname)),
+ p_result = func_get_detail(list_make1(makeString(proname)),
NIL, nargs, argtypes,
&p_funcid, &p_rettype,
&p_retset, &p_true_typeids);
switch (operform->oprkind)
{
case 'b':
- p_result = oper(makeList1(makeString(oprname)), arg1, arg2, true);
+ p_result = oper(list_make1(makeString(oprname)), arg1, arg2, true);
break;
case 'l':
- p_result = left_oper(makeList1(makeString(oprname)), arg2, true);
+ p_result = left_oper(list_make1(makeString(oprname)), arg2, true);
break;
case 'r':
- p_result = right_oper(makeList1(makeString(oprname)), arg1, true);
+ p_result = right_oper(list_make1(makeString(oprname)), arg1, true);
break;
default:
elog(ERROR, "unrecognized oprkind: %d", operform->oprkind);
print_operator_name(StringInfo buf, List *opname)
{
ListCell *op = list_head(opname);
- int nnames = length(opname);
+ int nnames = list_length(opname);
if (nnames == 1)
appendStringInfoString(buf, strVal(lfirst(op)));
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.159 2004/05/26 04:41:39 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.160 2004/05/30 23:40:36 neilc Exp $
*
*-------------------------------------------------------------------------
*/
if (eqopr == InvalidOid)
elog(ERROR, "no = operator for opclass %u", opclass);
- eqargs = makeList2(vardata.var, prefix);
+ eqargs = list_make2(vardata.var, prefix);
result = DatumGetFloat8(DirectFunctionCall4(eqsel,
PointerGetDatum(root),
ObjectIdGetDatum(eqopr),
return input_rows;
continue;
}
- allvars = nconc(allvars, varshere);
+ allvars = list_concat(allvars, varshere);
}
/* If now no Vars, we must have an all-constant GROUP BY list. */
if (allvars == NIL)
return 1.0;
- /* Use set_union() to discard duplicates */
- allvars = set_union(NIL, allvars);
+ /* Use list_union() to discard duplicates */
+ allvars = list_union(NIL, allvars);
/*
* Step 2: acquire statistical estimate of number of distinct values
ndistinct = get_variable_numdistinct(&vardata);
ReleaseVariableStats(vardata);
- /* cannot use foreach here because of possible lremove */
+ /* cannot use foreach here because of possible list_delete */
l2 = list_head(varinfos);
while (l2)
{
MyVarInfo *varinfo = (MyVarInfo *) lfirst(l2);
- /* must advance l2 before lremove possibly pfree's it */
+ /* must advance l2 before list_delete possibly pfree's it */
l2 = lnext(l2);
if (var->varno != varinfo->var->varno &&
else
{
/* Delete the older item */
- varinfos = lremove(varinfo, varinfos);
+ varinfos = list_delete_ptr(varinfos, varinfo);
}
}
}
VariableStatData rdata;
/* Fail if not a binary opclause (probably shouldn't happen) */
- if (length(args) != 2)
+ if (list_length(args) != 2)
return false;
left = (Node *) linitial(args);
Node *left,
*right;
- if (length(args) != 2)
+ if (list_length(args) != 2)
elog(ERROR, "join operator should take two arguments");
left = (Node *) linitial(args);
BTGreaterEqualStrategyNumber);
if (cmpopr == InvalidOid)
elog(ERROR, "no >= operator for opclass %u", opclass);
- cmpargs = makeList2(vardata->var, prefixcon);
+ cmpargs = list_make2(vardata->var, prefixcon);
/* Assume scalargtsel is appropriate for all supported types */
prefixsel = DatumGetFloat8(DirectFunctionCall4(scalargtsel,
PointerGetDatum(root),
BTLessStrategyNumber);
if (cmpopr == InvalidOid)
elog(ERROR, "no < operator for opclass %u", opclass);
- cmpargs = makeList2(vardata->var, greaterstrcon);
+ cmpargs = list_make2(vardata->var, greaterstrcon);
/* Assume scalarltsel is appropriate for all supported types */
topsel = DatumGetFloat8(DirectFunctionCall4(scalarltsel,
PointerGetDatum(root),
* eliminating duplicates is a bit trickier because indexQuals contains
* RestrictInfo nodes and the indpred does not. It is okay to pass a
* mixed list to clauselist_selectivity, but we have to work a bit to
- * generate a list without logical duplicates. (We could just set_union
+ * generate a list without logical duplicates. (We could just list_union
* indpred and strippedQuals, but then we'd not get caching of per-qual
* selectivity estimates.)
*/
List *predExtraQuals;
strippedQuals = get_actual_clauses(indexQuals);
- predExtraQuals = set_difference(index->indpred, strippedQuals);
- selectivityQuals = nconc(predExtraQuals, indexQuals);
+ predExtraQuals = list_difference(index->indpred, strippedQuals);
+ selectivityQuals = list_concat(predExtraQuals, indexQuals);
}
else
selectivityQuals = indexQuals;
* inaccuracies here ...
*/
cost_qual_eval(&index_qual_cost, indexQuals);
- qual_op_cost = cpu_operator_cost * length(indexQuals);
+ qual_op_cost = cpu_operator_cost * list_length(indexQuals);
qual_arg_cost = index_qual_cost.startup +
index_qual_cost.per_tuple - qual_op_cost;
if (qual_arg_cost < 0) /* just in case... */
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/tid.c,v 1.44 2004/05/26 04:41:39 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/tid.c,v 1.45 2004/05/30 23:40:36 neilc Exp $
*
* NOTES
* input routine largely stolen from boxin().
Query *query;
TargetEntry *tle;
- if (length(rewrite->actions) != 1)
+ if (list_length(rewrite->actions) != 1)
elog(ERROR, "only one select rule is allowed in views");
query = (Query *) linitial(rewrite->actions);
tle = get_tle_by_resno(query->targetList, tididx+1);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.113 2004/05/26 04:41:39 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.114 2004/05/30 23:40:36 neilc Exp $
*
*-------------------------------------------------------------------------
*/
}
pfree(rawname);
- freeList(namelist);
+ list_free(namelist);
return result;
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.203 2004/05/26 04:41:40 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.204 2004/05/30 23:40:37 neilc Exp $
*
*-------------------------------------------------------------------------
*/
pfree(relation->rd_am);
if (relation->rd_rel)
pfree(relation->rd_rel);
- freeList(relation->rd_indexlist);
+ list_free(relation->rd_indexlist);
if (relation->rd_indexcxt)
MemoryContextDelete(relation->rd_indexcxt);
}
}
- rebuildList = nconc(rebuildFirstList, rebuildList);
+ rebuildList = list_concat(rebuildFirstList, rebuildList);
/*
* Now zap any remaining smgr cache entries. This must happen before
relation = (Relation) lfirst(l);
RelationClearRelation(relation, true);
}
- freeList(rebuildList);
+ list_free(rebuildList);
}
/*
*/
if (relation->rd_indexvalid == 2)
{
- freeList(relation->rd_indexlist);
+ list_free(relation->rd_indexlist);
relation->rd_indexlist = NIL;
relation->rd_indexvalid = 0;
}
/* Quick exit if we already computed the list. */
if (relation->rd_indexvalid != 0)
- return listCopy(relation->rd_indexlist);
+ return list_copy(relation->rd_indexlist);
/*
* We build the list we intend to return (in the caller's context)
/* Now save a copy of the completed list in the relcache entry. */
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
- relation->rd_indexlist = listCopy(result);
+ relation->rd_indexlist = list_copy(result);
relation->rd_indexvalid = 1;
MemoryContextSwitchTo(oldcxt);
Assert(relation->rd_isnailed == 1);
/* Copy the list into the cache context (could fail for lack of mem) */
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
- indexIds = listCopy(indexIds);
+ indexIds = list_copy(indexIds);
MemoryContextSwitchTo(oldcxt);
/* Okay to replace old list */
- freeList(relation->rd_indexlist);
+ list_free(relation->rd_indexlist);
relation->rd_indexlist = indexIds;
relation->rd_indexvalid = 2; /* mark list as forced */
}
{
RelationCacheInsert(rels[relno]);
/* also make a list of their OIDs, for RelationIdIsInInitFile */
- initFileRelationIds = lconso(RelationGetRelid(rels[relno]),
+ initFileRelationIds = lcons_oid(RelationGetRelid(rels[relno]),
initFileRelationIds);
}
/* also make a list of their OIDs, for RelationIdIsInInitFile */
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
- initFileRelationIds = lconso(RelationGetRelid(rel),
+ initFileRelationIds = lcons_oid(RelationGetRelid(rel),
initFileRelationIds);
MemoryContextSwitchTo(oldcxt);
}
bool
RelationIdIsInInitFile(Oid relationId)
{
- return oidMember(relationId, initFileRelationIds);
+ return list_member_oid(initFileRelationIds, relationId);
}
/*
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.80 2004/01/19 02:06:41 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.81 2004/05/30 23:40:37 neilc Exp $
*
*-------------------------------------------------------------------------
*/
else
return InvalidOid;
- if (argnum < 0 || argnum >= length(args))
+ if (argnum < 0 || argnum >= list_length(args))
return InvalidOid;
- argtype = exprType((Node *) nth(argnum, args));
+ argtype = exprType((Node *) list_nth(args, argnum));
/*
* special hack for ScalarArrayOpExpr: what the underlying function
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.125 2004/05/26 04:41:43 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.126 2004/05/30 23:40:38 neilc Exp $
*
*-------------------------------------------------------------------------
*/
{
/* syntax error in list */
pfree(rawstring);
- freeList(elemlist);
+ list_free(elemlist);
ereport(LOG,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("invalid list syntax for parameter \"preload_libraries\"")));
}
pfree(rawstring);
- freeList(elemlist);
+ list_free(elemlist);
}
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.209 2004/05/29 22:48:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.210 2004/05/30 23:40:38 neilc Exp $
*
*--------------------------------------------------------------------
*/
{
/* syntax error in list */
pfree(rawstring);
- freeList(elemlist);
+ list_free(elemlist);
if (source >= PGC_S_INTERACTIVE)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognised \"log_destination\" key word: \"%s\"",
tok)));
pfree(rawstring);
- freeList(elemlist);
+ list_free(elemlist);
return NULL;
}
}
pfree(rawstring);
- freeList(elemlist);
+ list_free(elemlist);
/* If we aren't going to do the assignment, just return OK indicator. */
if (!doit)
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.64 2004/02/03 17:34:03 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.65 2004/05/30 23:40:39 neilc Exp $
*
*-------------------------------------------------------------------------
*/
AssertArg(PortalIsValid(portal));
AssertState(portal->queryContext == NULL); /* else defined already */
- Assert(length(parseTrees) == length(planTrees));
+ Assert(list_length(parseTrees) == list_length(planTrees));
Assert(commandTag != NULL || parseTrees == NIL);
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/pg_list.h,v 1.45 2004/05/26 19:30:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/pg_list.h,v 1.46 2004/05/30 23:40:39 neilc Exp $
*
*-------------------------------------------------------------------------
*/
#include "nodes/nodes.h"
-/*
- * As a temporary measure, enable the compatibility API unless the
- * include site specifically disabled it. Once the rest of the source
- * tree has been converted to the new API, this will be removed.
- */
-#ifndef DISABLE_LIST_COMPAT
-#define ENABLE_LIST_COMPAT
-#endif
-
/*
* This package implements singly-linked homogeneous lists. It is
* important to have constant-time length, append, and prepend
*/
typedef struct ListCell ListCell;
-typedef struct List List;
-struct List
+typedef struct List
{
NodeTag type; /* T_List, T_IntList, or T_OidList */
int length;
- ListCell *head;
- ListCell *tail;
-};
+ ListCell *head;
+ ListCell *tail;
+} List;
struct ListCell
{
#define linitial_int(l) lfirst_int(list_head(l))
#define linitial_oid(l) lfirst_oid(list_head(l))
+#define llast(l) lfirst(list_tail(l))
+#define llast_int(l) lfirst_int(list_tail(l))
+#define llast_oid(l) lfirst_oid(list_tail(l))
+
#define lsecond(l) lfirst(lnext(list_head(l)))
#define lsecond_int(l) lfirst_int(lnext(list_head(l)))
#define lsecond_oid(l) lfirst_oid(lnext(list_head(l)))
* simultaneously. This macro loops through both lists at the same
* time, stopping when either list runs out of elements. Depending
* on the requirements of the call site, it may also be wise to
- * ensure that the lengths of the two lists are equal.
+ * assert that the lengths of the two lists are equal.
*/
#define forboth(cell1, list1, cell2, list2) \
for ((cell1) = list_head(list1), (cell2) = list_head(list2); \
#define lfirsti(lc) lfirst_int(lc)
#define lfirsto(lc) lfirst_oid(lc)
-#define llast(l) lfirst(list_tail(l))
-
#define makeList1(x1) list_make1(x1)
#define makeList2(x1, x2) list_make2(x1, x2)
#define makeList3(x1, x2, x3) list_make3(x1, x2, x3)
extern int length(List *list);
-#endif
+#endif /* ENABLE_LIST_COMPAT */
-/*
- * Temporary hack: we define the FastList type whether the
- * compatibility API is enabled or not, since this allows files that
- * don't use the compatibility API to include headers that reference
- * the FastList type without an error.
- */
typedef struct FastList
{
List *list;
} FastList;
-#ifdef ENABLE_LIST_COMPAT
-
extern void FastListInit(FastList *fl);
extern void FastListFromList(FastList *fl, List *list);
extern List *FastListValue(FastList *fl);
extern void FastConc(FastList *fl, List *cells);
extern void FastConcFast(FastList *fl1, FastList *fl2);
-#endif
-
#endif /* PG_LIST_H */
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.98 2004/05/10 22:44:49 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.99 2004/05/30 23:40:39 neilc Exp $
*
*-------------------------------------------------------------------------
*/
* transforms INSERT/UPDATE tlists into a normalized form with exactly
* one entry for each column of the destination table. Before that's
* happened, however, it is risky to assume that resno == position.
- * Generally get_tle_by_resno() should be used rather than nth() to fetch
- * tlist entries by resno.
+ * Generally get_tle_by_resno() should be used rather than list_nth()
+ * to fetch tlist entries by resno.
*
* resname is required to represent the correct column name in non-resjunk
* entries of top-level SELECT targetlists, since it will be used as the
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.284 2004/05/26 13:57:04 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.285 2004/05/30 23:40:40 neilc Exp $ */
/* Copyright comment */
%{
/* func_name will soon return a List ... but not yet */
/*
func_name: function_name
- { $$ = makeList1(makeString($1)); }
+ { $$ = list_make1(makeString($1)); }
| dotted_name
{ $$ = $1; }
;
* procedural language
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.101 2004/05/26 04:41:48 neilc Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.102 2004/05/30 23:40:41 neilc Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
* 1. We can only evaluate queries that resulted in one single
* execution plan
*/
- if (length(spi_plan->ptlist) != 1)
+ if (list_length(spi_plan->ptlist) != 1)
return;
plan = (Plan *) linitial(spi_plan->ptlist);
/*
* 4. The plan must have a single attribute as result
*/
- if (length(plan->targetlist) != 1)
+ if (list_length(plan->targetlist) != 1)
return;
tle = (TargetEntry *) linitial(plan->targetlist);
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.84 2004/05/26 04:41:50 neilc Exp $
+ * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.85 2004/05/30 23:40:41 neilc Exp $
*
**********************************************************************/
qdesc->argtypelems[i] = ((Form_pg_type) GETSTRUCT(typeTup))->typelem;
ReleaseSysCache(typeTup);
- freeList(typename->names);
+ list_free(typename->names);
pfree(typename);
- freeList(names);
+ list_free(names);
pfree(argcopy);
}