Commit d0b4399d authored by Neil Conway's avatar Neil Conway

Reimplement the linked list data structure used throughout the backend.

In the past, we used a 'Lispy' linked list implementation: a "list" was
merely a pointer to the head node of the list. The problem with that
design is that it makes lappend() and length() linear time. This patch
fixes that problem (and others) by maintaining a count of the list
length and a pointer to the tail node along with each head node pointer.
A "list" is now a pointer to a structure containing some meta-data
about the list; the head and tail pointers in that structure refer
to ListCell structures that maintain the actual linked list of nodes.

The function names of the list API have also been changed to, I hope,
be more logically consistent. By default, the old function names are
still available; they will be disabled-by-default once the rest of
the tree has been updated to use the new API names.
parent 18d0d105
......@@ -9,7 +9,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.80 2004/01/07 18:56:23 neilc Exp $
* $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.81 2004/05/26 04:41:03 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -138,7 +138,7 @@ printtup_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
List *targetlist;
if (portal->strategy == PORTAL_ONE_SELECT)
targetlist = ((Query *) lfirst(portal->parseTrees))->targetList;
targetlist = ((Query *) linitial(portal->parseTrees))->targetList;
else
targetlist = NIL;
......@@ -176,6 +176,7 @@ SendRowDescriptionMessage(TupleDesc typeinfo, List *targetlist, int16 *formats)
int proto = PG_PROTOCOL_MAJOR(FrontendProtocol);
int i;
StringInfoData buf;
ListCell *tlist_item = list_head(targetlist);
pq_beginmessage(&buf, 'T'); /* tuple descriptor message type */
pq_sendint(&buf, natts, 2); /* # of attrs in tuples */
......@@ -191,16 +192,16 @@ SendRowDescriptionMessage(TupleDesc typeinfo, List *targetlist, int16 *formats)
if (proto >= 3)
{
/* Do we have a non-resjunk tlist item? */
while (targetlist &&
((TargetEntry *) lfirst(targetlist))->resdom->resjunk)
targetlist = lnext(targetlist);
if (targetlist)
while (tlist_item &&
((TargetEntry *) lfirst(tlist_item))->resdom->resjunk)
tlist_item = lnext(tlist_item);
if (tlist_item)
{
Resdom *res = ((TargetEntry *) lfirst(targetlist))->resdom;
Resdom *res = ((TargetEntry *) lfirst(tlist_item))->resdom;
pq_sendint(&buf, res->resorigtbl, 4);
pq_sendint(&buf, res->resorigcol, 2);
targetlist = lnext(targetlist);
tlist_item = lnext(tlist_item);
}
else
{
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/common/tupdesc.c,v 1.102 2004/04/01 21:28:43 tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/common/tupdesc.c,v 1.103 2004/05/26 04:41:03 neilc Exp $
*
* NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be
......@@ -472,7 +472,7 @@ BuildDescForRelation(List *schema)
{
int natts;
AttrNumber attnum;
List *p;
ListCell *l;
TupleDesc desc;
AttrDefault *attrdef = NULL;
TupleConstr *constr = (TupleConstr *) palloc0(sizeof(TupleConstr));
......@@ -490,9 +490,9 @@ BuildDescForRelation(List *schema)
attnum = 0;
foreach(p, schema)
foreach(l, schema)
{
ColumnDef *entry = lfirst(p);
ColumnDef *entry = lfirst(l);
/*
* for each entry in the list, get the name and type information
......@@ -661,7 +661,7 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
errmsg("number of aliases does not match number of columns")));
/* OK, get the column alias */
attname = strVal(lfirst(colaliases));
attname = strVal(linitial(colaliases));
tupdesc = CreateTemplateTupleDesc(1, false);
TupleDescInitEntry(tupdesc,
......
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.10 2004/01/07 18:56:24 neilc Exp $
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.11 2004/05/26 04:41:05 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -59,7 +59,7 @@ forget_matching_split(Relation reln, RelFileNode node,
Page page;
BTItem btitem;
BlockNumber rightblk;
List *l;
ListCell *l;
/* Get downlink TID from page */
buffer = XLogReadBuffer(false, reln, insertblk);
......@@ -964,7 +964,7 @@ btree_xlog_startup(void)
void
btree_xlog_cleanup(void)
{
List *l;
ListCell *l;
foreach(l, incomplete_splits)
{
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.67 2004/05/21 05:07:56 tgl Exp $
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.68 2004/05/26 04:41:05 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -271,7 +271,7 @@ Boot_BuildIndsStmt:
boot_index_params:
boot_index_params COMMA boot_index_param { $$ = lappend($1, $3); }
| boot_index_param { $$ = makeList1($1); }
| boot_index_param { $$ = list_make1($1); }
;
boot_index_param:
......@@ -280,7 +280,7 @@ boot_index_param:
IndexElem *n = makeNode(IndexElem);
n->name = LexIDStr($1);
n->expr = NULL;
n->opclass = makeList1(makeString(LexIDStr($2)));
n->opclass = list_make1(makeString(LexIDStr($2)));
$$ = n;
}
;
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.98 2004/05/11 17:36:12 tgl Exp $
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.99 2004/05/26 04:41:06 neilc Exp $
*
* NOTES
* See acl.h.
......@@ -110,7 +110,7 @@ merge_acl_with_grant(Acl *old_acl, bool is_grant,
AclId grantor_uid, AclId owner_uid)
{
unsigned modechg;
List *j;
ListCell *j;
Acl *new_acl;
modechg = is_grant ? ACL_MODECHG_ADD : ACL_MODECHG_DEL;
......@@ -221,16 +221,16 @@ static void
ExecuteGrantStmt_Relation(GrantStmt *stmt)
{
AclMode privileges;
List *i;
ListCell *i;
if (lfirsti(stmt->privileges) == ACL_ALL_RIGHTS)
if (linitial_int(stmt->privileges) == ACL_ALL_RIGHTS)
privileges = ACL_ALL_RIGHTS_RELATION;
else
{
privileges = ACL_NO_RIGHTS;
foreach(i, stmt->privileges)
{
AclMode priv = lfirsti(i);
AclMode priv = lfirst_int(i);
if (priv & ~((AclMode) ACL_ALL_RIGHTS_RELATION))
ereport(ERROR,
......@@ -328,16 +328,16 @@ static void
ExecuteGrantStmt_Database(GrantStmt *stmt)
{
AclMode privileges;
List *i;
ListCell *i;
if (lfirsti(stmt->privileges) == ACL_ALL_RIGHTS)
if (linitial_int(stmt->privileges) == ACL_ALL_RIGHTS)
privileges = ACL_ALL_RIGHTS_DATABASE;
else
{
privileges = ACL_NO_RIGHTS;
foreach(i, stmt->privileges)
{
AclMode priv = lfirsti(i);
AclMode priv = lfirst_int(i);
if (priv & ~((AclMode) ACL_ALL_RIGHTS_DATABASE))
ereport(ERROR,
......@@ -433,16 +433,16 @@ static void
ExecuteGrantStmt_Function(GrantStmt *stmt)
{
AclMode privileges;
List *i;
ListCell *i;
if (lfirsti(stmt->privileges) == ACL_ALL_RIGHTS)
if (linitial_int(stmt->privileges) == ACL_ALL_RIGHTS)
privileges = ACL_ALL_RIGHTS_FUNCTION;
else
{
privileges = ACL_NO_RIGHTS;
foreach(i, stmt->privileges)
{
AclMode priv = lfirsti(i);
AclMode priv = lfirst_int(i);
if (priv & ~((AclMode) ACL_ALL_RIGHTS_FUNCTION))
ereport(ERROR,
......@@ -534,16 +534,16 @@ static void
ExecuteGrantStmt_Language(GrantStmt *stmt)
{
AclMode privileges;
List *i;
ListCell *i;
if (lfirsti(stmt->privileges) == ACL_ALL_RIGHTS)
if (linitial_int(stmt->privileges) == ACL_ALL_RIGHTS)
privileges = ACL_ALL_RIGHTS_LANGUAGE;
else
{
privileges = ACL_NO_RIGHTS;
foreach(i, stmt->privileges)
{
AclMode priv = lfirsti(i);
AclMode priv = lfirst_int(i);
if (priv & ~((AclMode) ACL_ALL_RIGHTS_LANGUAGE))
ereport(ERROR,
......@@ -643,16 +643,16 @@ static void
ExecuteGrantStmt_Namespace(GrantStmt *stmt)
{
AclMode privileges;
List *i;
ListCell *i;
if (lfirsti(stmt->privileges) == ACL_ALL_RIGHTS)
if (linitial_int(stmt->privileges) == ACL_ALL_RIGHTS)
privileges = ACL_ALL_RIGHTS_NAMESPACE;
else
{
privileges = ACL_NO_RIGHTS;
foreach(i, stmt->privileges)
{
AclMode priv = lfirsti(i);
AclMode priv = lfirst_int(i);
if (priv & ~((AclMode) ACL_ALL_RIGHTS_NAMESPACE))
ereport(ERROR,
......
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.35 2004/05/05 04:48:45 tgl Exp $
* $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.36 2004/05/26 04:41:06 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -841,7 +841,7 @@ recordDependencyOnExpr(const ObjectAddress *depender,
init_object_addresses(&context.addrs);
/* Set up interpretation for Vars at varlevelsup = 0 */
context.rtables = makeList1(rtable);
context.rtables = list_make1(rtable);
/* Scan the expression tree for referenceable objects */
find_expr_references_walker(expr, &context);
......@@ -883,7 +883,7 @@ recordDependencyOnSingleRelExpr(const ObjectAddress *depender,
rte.rtekind = RTE_RELATION;
rte.relid = relId;
context.rtables = makeList1(makeList1(&rte));
context.rtables = list_make1(list_make1(&rte));
/* Scan the expression tree for referenceable objects */
find_expr_references_walker(expr, &context);
......@@ -960,24 +960,14 @@ find_expr_references_walker(Node *node,
if (IsA(node, Var))
{
Var *var = (Var *) node;
int levelsup;
List *rtable,
*rtables;
List *rtable;
RangeTblEntry *rte;
/* Find matching rtable entry, or complain if not found */
levelsup = var->varlevelsup;
rtables = context->rtables;
while (levelsup--)
{
if (rtables == NIL)
break;
rtables = lnext(rtables);
}
if (rtables == NIL)
if (var->varlevelsup >= list_length(context->rtables))
elog(ERROR, "invalid varlevelsup %d", var->varlevelsup);
rtable = lfirst(rtables);
if (var->varno <= 0 || var->varno > length(rtable))
rtable = (List *) list_nth(context->rtables, var->varlevelsup);
if (var->varno <= 0 || var->varno > list_length(rtable))
elog(ERROR, "invalid varno %d", var->varno);
rte = rt_fetch(var->varno, rtable);
if (rte->rtekind == RTE_RELATION)
......@@ -994,13 +984,15 @@ find_expr_references_walker(Node *node,
/* We must make the context appropriate for join's level */
save_rtables = context->rtables;
context->rtables = rtables;
context->rtables = list_copy_tail(context->rtables,
var->varlevelsup);
if (var->varattno <= 0 ||
var->varattno > length(rte->joinaliasvars))
var->varattno > list_length(rte->joinaliasvars))
elog(ERROR, "invalid varattno %d", var->varattno);
find_expr_references_walker((Node *) nth(var->varattno - 1,
rte->joinaliasvars),
find_expr_references_walker((Node *) list_nth(rte->joinaliasvars,
var->varattno - 1),
context);
list_free(context->rtables);
context->rtables = save_rtables;
}
return false;
......@@ -1056,11 +1048,11 @@ find_expr_references_walker(Node *node,
if (IsA(node, SubLink))
{
SubLink *sublink = (SubLink *) node;
List *opid;
ListCell *opid;
foreach(opid, sublink->operOids)
{
add_object_address(OCLASS_OPERATOR, lfirsto(opid), 0,
add_object_address(OCLASS_OPERATOR, lfirst_oid(opid), 0,
&context->addrs);
}
/* fall through to examine arguments */
......@@ -1074,7 +1066,7 @@ find_expr_references_walker(Node *node,
{
/* Recurse into RTE subquery or not-yet-planned sublink subquery */
Query *query = (Query *) node;
List *rtable;
ListCell *rtable;
bool result;
/*
......@@ -1099,7 +1091,7 @@ find_expr_references_walker(Node *node,
find_expr_references_walker,
(void *) context,
QTW_IGNORE_JOINALIASES);
context->rtables = lnext(context->rtables);
context->rtables = list_delete_first(context->rtables);
return result;
}
return expression_tree_walker(node, find_expr_references_walker,
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.264 2004/05/08 19:09:24 tgl Exp $
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.265 2004/05/26 04:41:07 neilc Exp $
*
*
* INTERFACE ROUTINES
......@@ -1379,11 +1379,11 @@ StoreRelCheck(Relation rel, char *ccname, char *ccbin)
* contents of subselects.
*/
varList = pull_var_clause(expr, false);
keycount = length(varList);
keycount = list_length(varList);
if (keycount > 0)
{
List *vl;
ListCell *vl;
int i = 0;
attNos = (int16 *) palloc(keycount * sizeof(int16));
......@@ -1505,7 +1505,7 @@ AddRelationRawConstraints(Relation rel,
RangeTblEntry *rte;
int numchecks;
int constr_name_ctr = 0;
List *listptr;
ListCell *cell;
Node *expr;
CookedConstraint *cooked;
......@@ -1540,9 +1540,9 @@ AddRelationRawConstraints(Relation rel,
/*
* Process column default expressions.
*/
foreach(listptr, rawColDefaults)
foreach(cell, rawColDefaults)
{
RawColumnDefault *colDef = (RawColumnDefault *) lfirst(listptr);
RawColumnDefault *colDef = (RawColumnDefault *) lfirst(cell);
Form_pg_attribute atp = rel->rd_att->attrs[colDef->attnum - 1];
expr = cookDefault(pstate, colDef->raw_default,
......@@ -1563,9 +1563,9 @@ AddRelationRawConstraints(Relation rel,
* Process constraint expressions.
*/
numchecks = numoldchecks;
foreach(listptr, rawConstraints)
foreach(cell, rawConstraints)
{
Constraint *cdef = (Constraint *) lfirst(listptr);
Constraint *cdef = (Constraint *) lfirst(cell);
char *ccname;
if (cdef->contype != CONSTR_CHECK || cdef->raw_expr == NULL)
......@@ -1575,7 +1575,7 @@ AddRelationRawConstraints(Relation rel,
/* Check name uniqueness, or generate a new name */
if (cdef->name != NULL)
{
List *listptr2;
ListCell *cell2;
ccname = cdef->name;
/* Check against pre-existing constraints */
......@@ -1589,9 +1589,9 @@ AddRelationRawConstraints(Relation rel,
ccname, RelationGetRelationName(rel))));
/* Check against other new constraints */
/* Needed because we don't do CommandCounterIncrement in loop */
foreach(listptr2, rawConstraints)
foreach(cell2, rawConstraints)
{
Constraint *cdef2 = (Constraint *) lfirst(listptr2);
Constraint *cdef2 = (Constraint *) lfirst(cell2);
if (cdef2 == cdef ||
cdef2->contype != CONSTR_CHECK ||
......@@ -1611,7 +1611,7 @@ AddRelationRawConstraints(Relation rel,
do
{
List *listptr2;
ListCell *cell2;
/*
* Generate a name that does not conflict with
......@@ -1629,9 +1629,9 @@ AddRelationRawConstraints(Relation rel,
* name.
*/
success = true;
foreach(listptr2, rawConstraints)
foreach(cell2, rawConstraints)
{
Constraint *cdef2 = (Constraint *) lfirst(listptr2);
Constraint *cdef2 = (Constraint *) lfirst(cell2);
if (cdef2 == cdef ||
cdef2->contype != CONSTR_CHECK ||
......@@ -1660,7 +1660,7 @@ AddRelationRawConstraints(Relation rel,
/*
* Make sure no outside relations are referred to.
*/
if (length(pstate->p_rtable) != 1)
if (list_length(pstate->p_rtable) != 1)
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("only table \"%s\" can be referenced in check constraint",
......@@ -1949,7 +1949,7 @@ static void
RelationTruncateIndexes(Oid heapId)
{
Relation heapRelation;
List *indlist;
ListCell *indlist;
/*
* Open the heap rel. We need grab no lock because we assume
......@@ -1960,7 +1960,7 @@ RelationTruncateIndexes(Oid heapId)
/* Ask the relcache to produce a list of the indexes of the rel */
foreach(indlist, RelationGetIndexList(heapRelation))
{
Oid indexId = lfirsto(indlist);
Oid indexId = lfirst_oid(indlist);
Relation currentIndex;
IndexInfo *indexInfo;
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.231 2004/05/08 19:09:24 tgl Exp $
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.232 2004/05/26 04:41:07 neilc Exp $
*
*
* INTERFACE ROUTINES
......@@ -88,7 +88,7 @@ ConstructTupleDescriptor(Relation heapRelation,
Oid *classObjectId)
{
int numatts = indexInfo->ii_NumIndexAttrs;
List *indexprs = indexInfo->ii_Expressions;
ListCell *indexpr_item = list_head(indexInfo->ii_Expressions);
TupleDesc heapTupDesc;
TupleDesc indexTupDesc;
int natts; /* #atts in heap rel --- for error checks */
......@@ -165,10 +165,10 @@ ConstructTupleDescriptor(Relation heapRelation,
/* Expressional index */
Node *indexkey;
if (indexprs == NIL) /* shouldn't happen */
if (indexpr_item == NULL) /* shouldn't happen */
elog(ERROR, "too few entries in indexprs list");
indexkey = (Node *) lfirst(indexprs);
indexprs = lnext(indexprs);
indexkey = (Node *) lfirst(indexpr_item);
indexpr_item = lnext(indexpr_item);
/*
* Make the attribute's name "pg_expresssion_nnn" (maybe think
......@@ -928,7 +928,7 @@ FormIndexDatum(IndexInfo *indexInfo,
Datum *datum,
char *nullv)
{
List *indexprs;
ListCell *indexpr_item;
int i;
if (indexInfo->ii_Expressions != NIL &&
......@@ -941,7 +941,7 @@ FormIndexDatum(IndexInfo *indexInfo,
/* Check caller has set up context correctly */
Assert(GetPerTupleExprContext(estate)->ecxt_scantuple->val == heapTuple);
}
indexprs = indexInfo->ii_ExpressionsState;
indexpr_item = list_head(indexInfo->ii_ExpressionsState);
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
{
......@@ -962,19 +962,19 @@ FormIndexDatum(IndexInfo *indexInfo,
/*
* Index expression --- need to evaluate it.
*/
if (indexprs == NIL)
if (indexpr_item == NULL)
elog(ERROR, "wrong number of index expressions");
iDatum = ExecEvalExprSwitchContext((ExprState *) lfirst(indexprs),
iDatum = ExecEvalExprSwitchContext((ExprState *) lfirst(indexpr_item),
GetPerTupleExprContext(estate),
&isNull,
NULL);
indexprs = lnext(indexprs);
indexpr_item = lnext(indexpr_item);
}
datum[i] = iDatum;
nullv[i] = (isNull) ? 'n' : ' ';
}
if (indexprs != NIL)
if (indexpr_item != NULL)
elog(ERROR, "wrong number of index expressions");
}
......@@ -1738,8 +1738,8 @@ reindex_relation(Oid relid, bool toast_too)
bool is_pg_class;
bool result;
List *indexIds,
*doneIndexes,
*indexId;
*doneIndexes;
ListCell *indexId;
/*
* Ensure to hold an exclusive lock throughout the transaction. The
......@@ -1780,7 +1780,7 @@ reindex_relation(Oid relid, bool toast_too)
/* Reindex all the indexes. */
foreach(indexId, indexIds)
{
Oid indexOid = lfirsto(indexId);
Oid indexOid = lfirst_oid(indexId);
if (is_pg_class)
RelationSetIndexList(rel, doneIndexes);
......@@ -1790,7 +1790,7 @@ reindex_relation(Oid relid, bool toast_too)
CommandCounterIncrement();
if (is_pg_class)
doneIndexes = lappendo(doneIndexes, indexOid);
doneIndexes = lappend_oid(doneIndexes, indexOid);
}
if (is_pg_class)
......
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.115 2004/04/02 23:14:05 tgl Exp $
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.116 2004/05/26 04:41:08 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -374,7 +374,7 @@ check_sql_fn_retval(Oid rettype, char fn_typtype, List *queryTreeList)
Query *parse;
int cmd;
List *tlist;
List *tlistitem;
ListCell *tlistitem;
int tlistlen;
Oid typerelid;
Oid restype;
......@@ -396,7 +396,7 @@ check_sql_fn_retval(Oid rettype, char fn_typtype, List *queryTreeList)
}
/* find the final query */
parse = (Query *) llast(queryTreeList);
parse = (Query *) lfirst(list_tail(queryTreeList));
cmd = parse->commandType;
tlist = parse->targetList;
......@@ -448,7 +448,7 @@ check_sql_fn_retval(Oid rettype, char fn_typtype, List *queryTreeList)
format_type_be(rettype)),
errdetail("Final SELECT must return exactly one column.")));
restype = ((TargetEntry *) lfirst(tlist))->resdom->restype;
restype = ((TargetEntry *) linitial(tlist))->resdom->restype;
if (!IsBinaryCoercible(restype, rettype))
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
......@@ -471,7 +471,7 @@ check_sql_fn_retval(Oid rettype, char fn_typtype, List *queryTreeList)
*/
if (tlistlen == 1)
{
restype = ((TargetEntry *) lfirst(tlist))->resdom->restype;
restype = ((TargetEntry *) linitial(tlist))->resdom->restype;
if (IsBinaryCoercible(restype, rettype))
return false; /* NOT returning whole tuple */
}
......@@ -556,7 +556,7 @@ check_sql_fn_retval(Oid rettype, char fn_typtype, List *queryTreeList)
*/
if (tlistlen == 1)
{
restype = ((TargetEntry *) lfirst(tlist))->resdom->restype;
restype = ((TargetEntry *) linitial(tlist))->resdom->restype;
if (IsBinaryCoercible(restype, rettype))
return false; /* NOT returning whole tuple */
}
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.17 2004/05/07 00:24:57 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.18 2004/05/26 04:41:09 neilc Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
......@@ -56,7 +56,7 @@ DefineAggregate(List *names, List *parameters)
char *initval = NULL;
Oid baseTypeId;
Oid transTypeId;
List *pl;
ListCell *pl;
/* Convert list of names to a name and namespace */
aggNamespace = QualifiedNameGetCreationNamespace(names, &aggName);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.6 2003/11/29 19:51:47 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.7 2004/05/26 04:41:09 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -41,7 +41,9 @@ ExecRenameStmt(RenameStmt *stmt)
switch (stmt->renameType)
{
case OBJECT_AGGREGATE:
RenameAggregate(stmt->object, (TypeName *) lfirst(stmt->objarg), stmt->newname);
RenameAggregate(stmt->object,
(TypeName *) linitial(stmt->objarg),
stmt->newname);
break;
case OBJECT_CONVERSION:
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.72 2004/05/23 21:24:02 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.73 2004/05/26 04:41:09 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -207,9 +207,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
*/
if (vacstmt->va_cols != NIL)
{
List *le;
ListCell *le;
vacattrstats = (VacAttrStats **) palloc(length(vacstmt->va_cols) *
vacattrstats = (VacAttrStats **) palloc(list_length(vacstmt->va_cols) *
sizeof(VacAttrStats *));
tcnt = 0;
foreach(le, vacstmt->va_cols)
......@@ -260,7 +260,7 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
thisdata->tupleFract = 1.0; /* fix later if partial */
if (indexInfo->ii_Expressions != NIL && vacstmt->va_cols == NIL)
{
List *indexprs = indexInfo->ii_Expressions;
ListCell *indexpr_item = list_head(indexInfo->ii_Expressions);
thisdata->vacattrstats = (VacAttrStats **)
palloc(indexInfo->ii_NumIndexAttrs * sizeof(VacAttrStats *));
......@@ -274,10 +274,10 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
/* Found an index expression */
Node *indexkey;
if (indexprs == NIL) /* shouldn't happen */
if (indexpr_item == NULL) /* shouldn't happen */
elog(ERROR, "too few entries in indexprs list");
indexkey = (Node *) lfirst(indexprs);
indexprs = lnext(indexprs);
indexkey = (Node *) lfirst(indexpr_item);
indexpr_item = lnext(indexpr_item);
/*
* Can't analyze if the opclass uses a storage type
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.111 2004/05/23 03:50:45 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.112 2004/05/26 04:41:10 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -932,7 +932,7 @@ NotifyMyFrontEnd(char *relname, int32 listenerPID)
static bool
AsyncExistsPendingNotify(const char *relname)
{
List *p;
ListCell *p;
foreach(p, pendingNotifies)
{
......
......@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.123 2004/05/08 00:34:49 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.124 2004/05/26 04:41:10 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -103,7 +103,7 @@ cluster(ClusterStmt *stmt)
if (stmt->indexname == NULL)
{
List *index;
ListCell *index;
/* We need to find the index that has indisclustered set. */
foreach(index, RelationGetIndexList(rel))
......@@ -111,7 +111,7 @@ cluster(ClusterStmt *stmt)
HeapTuple idxtuple;
Form_pg_index indexForm;
indexOid = lfirsto(index);
indexOid = lfirst_oid(index);
idxtuple = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(indexOid),
0, 0, 0);
......@@ -165,8 +165,8 @@ cluster(ClusterStmt *stmt)
* tables that have some index with indisclustered set.
*/
MemoryContext cluster_context;
List *rv,
*rvs;
List *rvs;
ListCell *rv;
/*
* We cannot run this form of CLUSTER inside a user transaction
......@@ -408,7 +408,7 @@ mark_index_clustered(Relation rel, Oid indexOid)
HeapTuple indexTuple;
Form_pg_index indexForm;
Relation pg_index;
List *index;
ListCell *index;
/*
* If the index is already marked clustered, no need to do anything.
......@@ -438,7 +438,7 @@ mark_index_clustered(Relation rel, Oid indexOid)
foreach(index, RelationGetIndexList(rel))
{
Oid thisIndexOid = lfirsto(index);
Oid thisIndexOid = lfirst_oid(index);
indexTuple = SearchSysCacheCopy(INDEXRELID,
ObjectIdGetDatum(thisIndexOid),
......
......@@ -7,7 +7,7 @@
* Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.76 2004/03/08 21:35:59 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.77 2004/05/26 04:41:10 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -379,11 +379,11 @@ CommentAttribute(List *qualname, char *comment)
AttrNumber attnum;
/* Separate relname and attr name */
nnames = length(qualname);
nnames = list_length(qualname);
if (nnames < 2) /* parser messed up */
elog(ERROR, "must specify relation and attribute");
relname = ltruncate(nnames - 1, listCopy(qualname));
attrname = strVal(llast(qualname));
relname = list_truncate(list_copy(qualname), nnames - 1);
attrname = strVal(lfirst(list_tail(qualname)));
/* Open the containing relation to ensure it won't go away meanwhile */
rel = makeRangeVarFromNameList(relname);
......@@ -429,11 +429,11 @@ CommentDatabase(List *qualname, char *comment)
char *database;
Oid oid;
if (length(qualname) != 1)
if (list_length(qualname) != 1)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("database name may not be qualified")));
database = strVal(lfirst(qualname));
database = strVal(linitial(qualname));
/*
* We cannot currently support cross-database comments (since other
......@@ -493,11 +493,11 @@ CommentNamespace(List *qualname, char *comment)
Oid classoid;
char *namespace;
if (length(qualname) != 1)
if (list_length(qualname) != 1)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("schema name may not be qualified")));
namespace = strVal(lfirst(qualname));
namespace = strVal(linitial(qualname));
oid = GetSysCacheOid(NAMESPACENAME,
CStringGetDatum(namespace),
......@@ -548,7 +548,7 @@ CommentRule(List *qualname, char *comment)
AclResult aclcheck;
/* Separate relname and trig name */
nnames = length(qualname);
nnames = list_length(qualname);
if (nnames == 1)
{
/* Old-style: only a rule name is given */
......@@ -556,7 +556,7 @@ CommentRule(List *qualname, char *comment)
HeapScanDesc scanDesc;
ScanKeyData scanKeyData;
rulename = strVal(lfirst(qualname));
rulename = strVal(linitial(qualname));
/* Search pg_rewrite for such a rule */
ScanKeyInit(&scanKeyData,
......@@ -599,8 +599,8 @@ CommentRule(List *qualname, char *comment)
{
/* New-style: rule and relname both provided */
Assert(nnames >= 2);
relname = ltruncate(nnames - 1, listCopy(qualname));
rulename = strVal(llast(qualname));
relname = list_truncate(list_copy(qualname), nnames - 1);
rulename = strVal(lfirst(list_tail(qualname)));
/* Open the owning relation to ensure it won't go away meanwhile */
rel = makeRangeVarFromNameList(relname);
......@@ -683,7 +683,7 @@ CommentType(List *typename, char *comment)
static void
CommentAggregate(List *aggregate, List *arguments, char *comment)
{
TypeName *aggtype = (TypeName *) lfirst(arguments);
TypeName *aggtype = (TypeName *) linitial(arguments);
Oid baseoid,
oid;
......@@ -750,7 +750,7 @@ CommentProc(List *function, List *arguments, char *comment)
static void
CommentOperator(List *opername, List *arguments, char *comment)
{
TypeName *typenode1 = (TypeName *) lfirst(arguments);
TypeName *typenode1 = (TypeName *) linitial(arguments);
TypeName *typenode2 = (TypeName *) lsecond(arguments);
Oid oid;
Oid classoid;
......@@ -794,11 +794,11 @@ CommentTrigger(List *qualname, char *comment)
Oid oid;
/* Separate relname and trig name */
nnames = length(qualname);
nnames = list_length(qualname);
if (nnames < 2) /* parser messed up */
elog(ERROR, "must specify relation and trigger");
relname = ltruncate(nnames - 1, listCopy(qualname));
trigname = strVal(llast(qualname));
relname = list_truncate(list_copy(qualname), nnames - 1);
trigname = strVal(lfirst(list_tail(qualname)));
/* Open the owning relation to ensure it won't go away meanwhile */
rel = makeRangeVarFromNameList(relname);
......@@ -872,11 +872,11 @@ CommentConstraint(List *qualname, char *comment)
Oid conOid = InvalidOid;
/* Separate relname and constraint name */
nnames = length(qualname);
nnames = list_length(qualname);
if (nnames < 2) /* parser messed up */
elog(ERROR, "must specify relation and constraint");
relName = ltruncate(nnames - 1, listCopy(qualname));
conName = strVal(llast(qualname));
relName = list_truncate(list_copy(qualname), nnames - 1);
conName = strVal(lfirst(list_tail(qualname)));
/* Open the owning relation to ensure it won't go away meanwhile */
rel = makeRangeVarFromNameList(relName);
......@@ -985,11 +985,11 @@ CommentLanguage(List *qualname, char *comment)
Oid classoid;
char *language;
if (length(qualname) != 1)
if (list_length(qualname) != 1)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("language name may not be qualified")));
language = strVal(lfirst(qualname));
language = strVal(linitial(qualname));
oid = GetSysCacheOid(LANGNAME,
CStringGetDatum(language),
......@@ -1032,8 +1032,8 @@ CommentOpClass(List *qualname, List *arguments, char *comment)
Oid classoid;
HeapTuple tuple;
Assert(length(arguments) == 1);
amname = strVal(lfirst(arguments));
Assert(list_length(arguments) == 1);
amname = strVal(linitial(arguments));
/*
* Get the access method's OID.
......@@ -1118,8 +1118,8 @@ CommentLargeObject(List *qualname, char *comment)
Oid classoid;
Node *node;
Assert(length(qualname) == 1);
node = (Node *) lfirst(qualname);
Assert(list_length(qualname) == 1);
node = (Node *) linitial(qualname);
switch (nodeTag(node))
{
......@@ -1176,11 +1176,11 @@ CommentCast(List *qualname, List *arguments, char *comment)
Oid castOid;
Oid classoid;
Assert(length(qualname) == 1);
sourcetype = (TypeName *) lfirst(qualname);
Assert(list_length(qualname) == 1);
sourcetype = (TypeName *) linitial(qualname);
Assert(IsA(sourcetype, TypeName));
Assert(length(arguments) == 1);
targettype = (TypeName *) lfirst(arguments);
Assert(list_length(arguments) == 1);
targettype = (TypeName *) linitial(arguments);
Assert(IsA(targettype, TypeName));
sourcetypeid = typenameTypeId(sourcetype);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.223 2004/04/21 00:34:18 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.224 2004/05/26 04:41:10 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -685,7 +685,7 @@ DoCopy(const CopyStmt *stmt)
char *filename = stmt->filename;
bool is_from = stmt->is_from;
bool pipe = (stmt->filename == NULL);
List *option;
ListCell *option;
List *attnamelist = stmt->attlist;
List *attnumlist;
bool binary = false;
......@@ -934,15 +934,15 @@ DoCopy(const CopyStmt *stmt)
{
TupleDesc tupDesc = RelationGetDescr(rel);
Form_pg_attribute *attr = tupDesc->attrs;
List *cur;
ListCell *cur;
force_quote_atts = CopyGetAttnums(rel, force_quote);
foreach(cur, force_quote_atts)
{
int attnum = lfirsti(cur);
int attnum = lfirst_int(cur);
if (!intMember(attnum, attnumlist))
if (!list_member_int(attnumlist, attnum))
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("FORCE QUOTE column \"%s\" not referenced by COPY",
......@@ -955,7 +955,7 @@ DoCopy(const CopyStmt *stmt)
*/
if (force_notnull)
{
List *cur;
ListCell *cur;
TupleDesc tupDesc = RelationGetDescr(rel);
Form_pg_attribute *attr = tupDesc->attrs;
......@@ -963,9 +963,9 @@ DoCopy(const CopyStmt *stmt)
foreach(cur, force_notnull_atts)
{
int attnum = lfirsti(cur);
int attnum = lfirst_int(cur);
if (!intMember(attnum, attnumlist))
if (!list_member_int(attnumlist, attnum))
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("FORCE NOT NULL column \"%s\" not referenced by COPY",
......@@ -1011,7 +1011,7 @@ DoCopy(const CopyStmt *stmt)
if (pipe)
{
if (whereToSendOutput == Remote)
ReceiveCopyBegin(binary, length(attnumlist));
ReceiveCopyBegin(binary, list_length(attnumlist));
else
copy_file = stdin;
}
......@@ -1062,7 +1062,7 @@ DoCopy(const CopyStmt *stmt)
if (pipe)
{
if (whereToSendOutput == Remote)
SendCopyBegin(binary, length(attnumlist));
SendCopyBegin(binary, list_length(attnumlist));
else
copy_file = stdout;
}
......@@ -1147,14 +1147,14 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
bool *isvarlena;
char *string;
Snapshot mySnapshot;
List *cur;
ListCell *cur;
MemoryContext oldcontext;
MemoryContext mycontext;
tupDesc = rel->rd_att;
attr = tupDesc->attrs;
num_phys_attrs = tupDesc->natts;
attr_count = length(attnumlist);
attr_count = list_length(attnumlist);
/*
* Get info about the columns we need to process.
......@@ -1167,7 +1167,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
force_quote = (bool *) palloc((num_phys_attrs + 1) * sizeof(bool));
foreach(cur, attnumlist)
{
int attnum = lfirsti(cur);
int attnum = lfirst_int(cur);
Oid out_func_oid;
if (binary)
......@@ -1180,7 +1180,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
&isvarlena[attnum - 1]);
fmgr_info(out_func_oid, &out_functions[attnum - 1]);
if (intMember(attnum, force_quote_atts))
if (list_member_int(force_quote_atts, attnum))
force_quote[attnum - 1] = true;
else
force_quote[attnum - 1] = false;
......@@ -1266,7 +1266,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
foreach(cur, attnumlist)
{
int attnum = lfirsti(cur);
int attnum = lfirst_int(cur);
Datum value;
bool isnull;
......@@ -1451,7 +1451,6 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
bool hasConstraints = false;
int attnum;
int i;
List *cur;
Oid in_func_oid;
Datum *values;
char *nulls;
......@@ -1471,7 +1470,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
tupDesc = RelationGetDescr(rel);
attr = tupDesc->attrs;
num_phys_attrs = tupDesc->natts;
attr_count = length(attnumlist);
attr_count = list_length(attnumlist);
num_defaults = 0;
/*
......@@ -1526,13 +1525,13 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
&in_func_oid, &elements[attnum - 1]);
fmgr_info(in_func_oid, &in_functions[attnum - 1]);
if (intMember(attnum, force_notnull_atts))
if (list_member_int(force_notnull_atts, attnum))
force_notnull[attnum - 1] = true;
else
force_notnull[attnum - 1] = false;
/* Get default info if needed */
if (!intMember(attnum, attnumlist))
if (!list_member_int(attnumlist, attnum))
{
/* attribute is NOT to be copied from input */
/* use default value if one exists */
......@@ -1681,6 +1680,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
{
CopyReadResult result = NORMAL_ATTR;
char *string;
ListCell *cur;
/* Actually read the line into memory here */
done = CopyReadLine();
......@@ -1722,7 +1722,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
*/
foreach(cur, attnumlist)
{
int attnum = lfirsti(cur);
int attnum = lfirst_int(cur);
int m = attnum - 1;
/*
......@@ -1783,6 +1783,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
{
/* binary */
int16 fld_count;
ListCell *cur;
fld_count = CopyGetInt16();
if (CopyGetEof() || fld_count == -1)
......@@ -1815,7 +1816,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
i = 0;
foreach(cur, attnumlist)
{
int attnum = lfirsti(cur);
int attnum = lfirst_int(cur);
int m = attnum - 1;
copy_attname = NameStr(attr[m]->attname);
......@@ -2642,13 +2643,13 @@ CopyGetAttnums(Relation rel, List *attnamelist)
{
if (attr[i]->attisdropped)
continue;
attnums = lappendi(attnums, i + 1);
attnums = lappend_int(attnums, i + 1);
}
}
else
{
/* Validate the user-supplied list and extract attnums */
List *l;
ListCell *l;
foreach(l, attnamelist)
{
......@@ -2659,12 +2660,12 @@ CopyGetAttnums(Relation rel, List *attnamelist)
/* Note we disallow system columns here */
attnum = attnameAttNum(rel, name, false);
/* Check for duplicates */
if (intMember(attnum, attnums))
if (list_member_int(attnums, attnum))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_COLUMN),
errmsg("column \"%s\" specified more than once",
name)));
attnums = lappendi(attnums, attnum);
attnums = lappend_int(attnums, attnum);
}
}
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.132 2004/04/19 17:42:57 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.133 2004/05/26 04:41:10 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -82,7 +82,7 @@ createdb(const CreatedbStmt *stmt)
char new_record_nulls[Natts_pg_database];
Oid dboid;
AclId datdba;
List *option;
ListCell *option;
DefElem *downer = NULL;
DefElem *dpath = NULL;
DefElem *dtemplate = NULL;
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/define.c,v 1.88 2004/05/14 16:11:25 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/define.c,v 1.89 2004/05/26 04:41:10 neilc Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
......@@ -190,7 +190,7 @@ defGetQualifiedName(DefElem *def)
return (List *) def->arg;
case T_String:
/* Allow quoted name for backwards compatibility */
return makeList1(def->arg);
return list_make1(def->arg);
default:
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
......@@ -223,7 +223,7 @@ defGetTypeName(DefElem *def)
/* Allow quoted typename for backwards compatibility */
TypeName *n = makeNode(TypeName);
n->names = makeList1(def->arg);
n->names = list_make1(def->arg);
n->typmod = -1;
return n;
}
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994-5, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.120 2004/04/01 21:28:44 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.121 2004/05/26 04:41:10 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -72,7 +72,7 @@ ExplainQuery(ExplainStmt *stmt, DestReceiver *dest)
Query *query = stmt->query;
TupOutputState *tstate;
List *rewritten;
List *l;
ListCell *l;
/* prepare for projection of tuples */
tstate = begin_tup_output_tupdesc(dest, ExplainResultDesc(stmt));
......@@ -104,7 +104,7 @@ ExplainQuery(ExplainStmt *stmt, DestReceiver *dest)
{
ExplainOneQuery(lfirst(l), stmt, tstate);
/* put a blank line between plans */
if (lnext(l) != NIL)
if (lnext(l) != NULL)
do_text_output_oneline(tstate, "");
}
}
......@@ -156,9 +156,9 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate)
/* Still need to rewrite cursor command */
Assert(query->commandType == CMD_SELECT);
rewritten = QueryRewrite(query);
if (length(rewritten) != 1)
if (list_length(rewritten) != 1)
elog(ERROR, "unexpected rewrite result");
query = (Query *) lfirst(rewritten);
query = (Query *) linitial(rewritten);
Assert(query->commandType == CMD_SELECT);
/* do not actually execute the underlying query! */
stmt->analyze = false;
......@@ -317,7 +317,7 @@ explain_outNode(StringInfo str,
Plan *outer_plan,
int indent, ExplainState *es)
{
List *l;
ListCell *l;
char *pname;
int i;
......@@ -491,7 +491,7 @@ explain_outNode(StringInfo str,
{
Relation relation;
relation = index_open(lfirsto(l));
relation = index_open(lfirst_oid(l));
appendStringInfo(str, "%s%s",
(++i > 1) ? ", " : "",
quote_identifier(RelationGetRelationName(relation)));
......@@ -699,7 +699,7 @@ explain_outNode(StringInfo str,
if (plan->initPlan)
{
List *saved_rtable = es->rtable;
List *lst;
ListCell *lst;
for (i = 0; i < indent; i++)
appendStringInfo(str, " ");
......@@ -749,7 +749,7 @@ explain_outNode(StringInfo str,
{
Append *appendplan = (Append *) plan;
AppendState *appendstate = (AppendState *) planstate;
List *lst;
ListCell *lst;
int j;
j = 0;
......@@ -797,7 +797,7 @@ explain_outNode(StringInfo str,
if (planstate->subPlan)
{
List *saved_rtable = es->rtable;
List *lst;
ListCell *lst;
for (i = 0; i < indent; i++)
appendStringInfo(str, " ");
......@@ -839,11 +839,8 @@ show_scan_qual(List *qual, bool is_or_qual, const char *qlabel,
/* No work if empty qual */
if (qual == NIL)
return;
if (is_or_qual)
{
if (lfirst(qual) == NIL && lnext(qual) == NIL)
if (is_or_qual && list_length(qual) == 1 && linitial(qual) == NIL)
return;
}
/* Fix qual --- indexqual requires different processing */
if (is_or_qual)
......@@ -852,7 +849,7 @@ show_scan_qual(List *qual, bool is_or_qual, const char *qlabel,
node = (Node *) make_ands_explicit(qual);
/* Generate deparse context */
Assert(scanrelid > 0 && scanrelid <= length(es->rtable));
Assert(scanrelid > 0 && scanrelid <= list_length(es->rtable));
rte = rt_fetch(scanrelid, es->rtable);
scancontext = deparse_context_for_rte(rte);
......@@ -984,7 +981,7 @@ show_sort_keys(List *tlist, int nkeys, AttrNumber *keycols,
context = deparse_context_for_plan(0, NULL,
0, NULL,
es->rtable);
useprefix = length(es->rtable) > 1;
useprefix = list_length(es->rtable) > 1;
}
bms_free(varnos);
......@@ -1017,17 +1014,16 @@ make_ors_ands_explicit(List *orclauses)
{
if (orclauses == NIL)
return NULL; /* probably can't happen */
else if (lnext(orclauses) == NIL)
return (Node *) make_ands_explicit(lfirst(orclauses));
else if (list_length(orclauses) == 1)
return (Node *) make_ands_explicit(linitial(orclauses));
else
{
FastList args;
List *orptr;
List *args = NIL;
ListCell *orptr;
FastListInit(&args);
foreach(orptr, orclauses)
FastAppend(&args, make_ands_explicit(lfirst(orptr)));
args = lappend(args, make_ands_explicit(lfirst(orptr)));
return (Node *) make_orclause(FastListValue(&args));
return (Node *) make_orclause(args);
}
}
......@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.46 2004/05/14 16:11:25 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.47 2004/05/26 04:41:11 neilc Exp $
*
* DESCRIPTION
* These routines take the parse tree and pick out the
......@@ -137,7 +137,7 @@ examine_parameter_list(List *parameter, Oid languageOid,
Oid *parameterTypes, const char *parameterNames[])
{
int parameterCount = 0;
List *x;
ListCell *x;
MemSet(parameterTypes, 0, FUNC_MAX_ARGS * sizeof(Oid));
MemSet(parameterNames, 0, FUNC_MAX_ARGS * sizeof(char *));
......@@ -202,14 +202,14 @@ examine_parameter_list(List *parameter, Oid languageOid,
*/
static void
compute_attributes_sql_style(const List *options,
compute_attributes_sql_style(List *options,
List **as,
char **language,
char *volatility_p,
bool *strict_p,
bool *security_definer)
{
const List *option;
ListCell *option;
DefElem *as_item = NULL;
DefElem *language_item = NULL;
DefElem *volatility_item = NULL;
......@@ -322,7 +322,7 @@ compute_attributes_sql_style(const List *options,
static void
compute_attributes_with_style(List *parameters, bool *isStrict_p, char *volatility_p)
{
List *pl;
ListCell *pl;
foreach(pl, parameters)
{
......@@ -357,7 +357,7 @@ compute_attributes_with_style(List *parameters, bool *isStrict_p, char *volatili
*/
static void
interpret_AS_clause(Oid languageOid, const char *languageName, const List *as,
interpret_AS_clause(Oid languageOid, const char *languageName, List *as,
char **prosrc_str_p, char **probin_str_p)
{
Assert(as != NIL);
......@@ -368,8 +368,8 @@ interpret_AS_clause(Oid languageOid, const char *languageName, const List *as,
* For "C" language, store the file name in probin and, when
* given, the link symbol name in prosrc.
*/
*probin_str_p = strVal(lfirst(as));
if (lnext(as) == NULL)
*probin_str_p = strVal(linitial(as));
if (list_length(as) == 1)
*prosrc_str_p = "-";
else
*prosrc_str_p = strVal(lsecond(as));
......@@ -377,10 +377,10 @@ interpret_AS_clause(Oid languageOid, const char *languageName, const List *as,
else
{
/* Everything else wants the given string in prosrc. */
*prosrc_str_p = strVal(lfirst(as));
*prosrc_str_p = strVal(linitial(as));
*probin_str_p = "-";
if (lnext(as) != NIL)
if (list_length(as) != 1)
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("only one AS item needed for language \"%s\"",
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.119 2004/05/08 00:34:49 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.120 2004/05/26 04:41:11 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -109,7 +109,7 @@ DefineIndex(RangeVar *heapRelation,
/*
* count attributes in index
*/
numberOfAttributes = length(attributeList);
numberOfAttributes = list_length(attributeList);
if (numberOfAttributes <= 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
......@@ -165,7 +165,7 @@ DefineIndex(RangeVar *heapRelation,
namespaceId);
else
{
IndexElem *iparam = (IndexElem *) lfirst(attributeList);
IndexElem *iparam = (IndexElem *) linitial(attributeList);
indexRelationName = CreateIndexName(RelationGetRelationName(rel),
iparam->name,
......@@ -208,7 +208,7 @@ DefineIndex(RangeVar *heapRelation,
*/
if (rangetable != NIL)
{
if (length(rangetable) != 1 || getrelid(1, rangetable) != relationId)
if (list_length(rangetable) != 1 || getrelid(1, rangetable) != relationId)
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("index expressions and predicates may refer only to the table being indexed")));
......@@ -226,7 +226,7 @@ DefineIndex(RangeVar *heapRelation,
if (primary)
{
List *cmds;
List *keys;
ListCell *keys;
/*
* If ALTER TABLE, check that there isn't already a PRIMARY KEY.
......@@ -399,7 +399,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
Oid accessMethodId,
bool isconstraint)
{
List *rest;
ListCell *rest;
int attn = 0;
/*
......@@ -516,9 +516,9 @@ GetIndexOpClass(List *opclass, Oid attrType,
* Release 7.5 removes bigbox_ops (which was dead code for a long while
* anyway). tgl 2003/11/11
*/
if (length(opclass) == 1)
if (list_length(opclass) == 1)
{
char *claname = strVal(lfirst(opclass));
char *claname = strVal(linitial(opclass));
if (strcmp(claname, "network_ops") == 0 ||
strcmp(claname, "timespan_ops") == 0 ||
......@@ -697,8 +697,8 @@ static bool
relationHasPrimaryKey(Relation rel)
{
bool result = false;
List *indexoidlist,
*indexoidscan;
List *indexoidlist;
ListCell *indexoidscan;
/*
* Get the list of index OIDs for the table from the relcache, and
......@@ -709,7 +709,7 @@ relationHasPrimaryKey(Relation rel)
foreach(indexoidscan, indexoidlist)
{
Oid indexoid = lfirsto(indexoidscan);
Oid indexoid = lfirst_oid(indexoidscan);
HeapTuple indexTuple;
indexTuple = SearchSysCache(INDEXRELID,
......@@ -723,7 +723,7 @@ relationHasPrimaryKey(Relation rel)
break;
}
freeList(indexoidlist);
list_free(indexoidlist);
return result;
}
......@@ -849,6 +849,7 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */,
MemoryContext private_context;
MemoryContext old;
List *relids = NIL;
ListCell *l;
AssertArg(dbname);
......@@ -887,7 +888,7 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */,
* reindexing itself will try to update pg_class.
*/
old = MemoryContextSwitchTo(private_context);
relids = lappendo(relids, RelOid_pg_class);
relids = lappend_oid(relids, RelOid_pg_class);
MemoryContextSwitchTo(old);
/*
......@@ -921,7 +922,7 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */,
continue; /* got it already */
old = MemoryContextSwitchTo(private_context);
relids = lappendo(relids, HeapTupleGetOid(tuple));
relids = lappend_oid(relids, HeapTupleGetOid(tuple));
MemoryContextSwitchTo(old);
}
heap_endscan(scan);
......@@ -929,9 +930,9 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */,
/* Now reindex each rel in a separate transaction */
CommitTransactionCommand();
while (relids)
foreach(l, relids)
{
Oid relid = lfirsto(relids);
Oid relid = lfirst_oid(l);
StartTransactionCommand();
SetQuerySnapshot(); /* might be needed for functions in
......@@ -941,7 +942,6 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */,
(errmsg("table \"%s\" was reindexed",
get_rel_name(relid))));
CommitTransactionCommand();
relids = lnext(relids);
}
StartTransactionCommand();
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/lockcmds.c,v 1.9 2004/03/11 01:47:35 ishii Exp $
* $PostgreSQL: pgsql/src/backend/commands/lockcmds.c,v 1.10 2004/05/26 04:41:11 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -28,7 +28,7 @@
void
LockTableCommand(LockStmt *lockstmt)
{
List *p;
ListCell *p;
/*
* Iterate over the list and open, lock, and close the relations one
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.24 2003/11/29 19:51:47 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.25 2004/05/26 04:41:11 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -77,7 +77,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
numProcs; /* amsupport value */
List *operators; /* OpClassMember list for operators */
List *procedures; /* OpClassMember list for support procs */
List *l;
ListCell *l;
Relation rel;
HeapTuple tup;
Datum values[Natts_pg_opclass];
......@@ -168,7 +168,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
item->number, numOperators)));
if (item->args != NIL)
{
TypeName *typeName1 = (TypeName *) lfirst(item->args);
TypeName *typeName1 = (TypeName *) linitial(item->args);
TypeName *typeName2 = (TypeName *) lsecond(item->args);
operOid = LookupOperNameTypeNames(item->name,
......@@ -506,7 +506,7 @@ assignProcSubtype(Oid amoid, Oid typeoid, Oid procOid)
static void
addClassMember(List **list, OpClassMember *member, bool isProc)
{
List *l;
ListCell *l;
foreach(l, *list)
{
......@@ -540,7 +540,7 @@ storeOperators(Oid opclassoid, List *operators)
Datum values[Natts_pg_amop];
char nulls[Natts_pg_amop];
HeapTuple tup;
List *l;
ListCell *l;
int i;
rel = heap_openr(AccessMethodOperatorRelationName, RowExclusiveLock);
......@@ -584,7 +584,7 @@ storeProcedures(Oid opclassoid, List *procedures)
Datum values[Natts_pg_amproc];
char nulls[Natts_pg_amproc];
HeapTuple tup;
List *l;
ListCell *l;
int i;
rel = heap_openr(AccessMethodProcedureRelationName, RowExclusiveLock);
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/operatorcmds.c,v 1.15 2004/05/14 16:11:25 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/operatorcmds.c,v 1.16 2004/05/26 04:41:11 neilc Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
......@@ -79,7 +79,7 @@ DefineOperator(List *names, List *parameters)
List *rightSortName = NIL; /* optional right sort operator */
List *ltCompareName = NIL; /* optional < compare operator */
List *gtCompareName = NIL; /* optional > compare operator */
List *pl;
ListCell *pl;
/* Convert list of names to a name and namespace */
oprNamespace = QualifiedNameGetCreationNamespace(names, &oprName);
......@@ -167,13 +167,13 @@ DefineOperator(List *names, List *parameters)
if (canMerge)
{
if (!leftSortName)
leftSortName = makeList1(makeString("<"));
leftSortName = list_make1(makeString("<"));
if (!rightSortName)
rightSortName = makeList1(makeString("<"));
rightSortName = list_make1(makeString("<"));
if (!ltCompareName)
ltCompareName = makeList1(makeString("<"));
ltCompareName = list_make1(makeString("<"));
if (!gtCompareName)
gtCompareName = makeList1(makeString(">"));
gtCompareName = list_make1(makeString(">"));
}
/*
......@@ -206,7 +206,7 @@ void
RemoveOperator(RemoveOperStmt *stmt)
{
List *operatorName = stmt->opname;
TypeName *typeName1 = (TypeName *) lfirst(stmt->args);
TypeName *typeName1 = (TypeName *) linitial(stmt->args);
TypeName *typeName2 = (TypeName *) lsecond(stmt->args);
Oid operOid;
HeapTuple tup;
......
......@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.26 2004/03/21 22:29:10 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.27 2004/05/26 04:41:11 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -68,9 +68,9 @@ PerformCursorOpen(DeclareCursorStmt *stmt)
* strange.
*/
rewritten = QueryRewrite((Query *) stmt->query);
if (length(rewritten) != 1 || !IsA(lfirst(rewritten), Query))
if (list_length(rewritten) != 1 || !IsA(linitial(rewritten), Query))
elog(ERROR, "unexpected rewrite result");
query = (Query *) lfirst(rewritten);
query = (Query *) linitial(rewritten);
if (query->commandType != CMD_SELECT)
elog(ERROR, "unexpected rewrite result");
......@@ -100,8 +100,8 @@ PerformCursorOpen(DeclareCursorStmt *stmt)
PortalDefineQuery(portal,
NULL, /* unfortunately don't have sourceText */
"SELECT", /* cursor's query is always a SELECT */
makeList1(query),
makeList1(plan),
list_make1(query),
list_make1(plan),
PortalGetHeapMemory(portal));
MemoryContextSwitchTo(oldContext);
......
......@@ -10,7 +10,7 @@
* Copyright (c) 2002-2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.26 2004/04/22 02:58:20 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.27 2004/05/26 04:41:11 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -125,7 +125,7 @@ ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest, char *completionTag)
plan_list = entry->plan_list;
qcontext = entry->context;
Assert(length(query_list) == length(plan_list));
Assert(list_length(query_list) == list_length(plan_list));
/* Evaluate parameters, if any */
if (entry->argtype_list != NIL)
......@@ -162,11 +162,11 @@ ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest, char *completionTag)
plan_list = copyObject(plan_list);
qcontext = PortalGetHeapMemory(portal);
if (length(query_list) != 1)
if (list_length(query_list) != 1)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("prepared statement is not a SELECT")));
query = (Query *) lfirst(query_list);
query = (Query *) linitial(query_list);
if (query->commandType != CMD_SELECT)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
......@@ -208,14 +208,14 @@ ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest, char *completionTag)
static ParamListInfo
EvaluateParams(EState *estate, List *params, List *argtypes)
{
int nargs = length(argtypes);
int nargs = list_length(argtypes);
ParamListInfo paramLI;
List *exprstates;
List *l;
ListCell *l;
int i = 0;
/* Parser should have caught this error, but check for safety */
if (length(params) != nargs)
if (list_length(params) != nargs)
elog(ERROR, "wrong number of arguments");
exprstates = (List *) ExecPrepareExpr((Expr *) params, estate);
......@@ -326,7 +326,7 @@ StorePreparedStatement(const char *stmt_name,
qstring = query_string ? pstrdup(query_string) : NULL;
query_list = (List *) copyObject(query_list);
plan_list = (List *) copyObject(plan_list);
argtype_list = listCopy(argtype_list);
argtype_list = list_copy(argtype_list);
/* Now we can add entry to hash table */
entry = (PreparedStatement *) hash_search(prepared_queries,
......@@ -419,11 +419,11 @@ FetchPreparedStatementResultDesc(PreparedStatement *stmt)
switch (ChoosePortalStrategy(stmt->query_list))
{
case PORTAL_ONE_SELECT:
query = (Query *) lfirst(stmt->query_list);
query = (Query *) linitial(stmt->query_list);
return ExecCleanTypeFromTL(query->targetList, false);
case PORTAL_UTIL_SELECT:
query = (Query *) lfirst(stmt->query_list);
query = (Query *) linitial(stmt->query_list);
return UtilityTupleDescriptor(query->utilityStmt);
case PORTAL_MULTI_QUERY:
......@@ -478,8 +478,9 @@ ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate)
{
ExecuteStmt *execstmt = (ExecuteStmt *) stmt->query->utilityStmt;
PreparedStatement *entry;
List *l,
*query_list,
ListCell *q,
*p;
List *query_list,
*plan_list;
ParamListInfo paramLI = NULL;
EState *estate = NULL;
......@@ -493,7 +494,7 @@ ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate)
query_list = entry->query_list;
plan_list = entry->plan_list;
Assert(length(query_list) == length(plan_list));
Assert(list_length(query_list) == list_length(plan_list));
/* Evaluate parameters, if any */
if (entry->argtype_list != NIL)
......@@ -508,14 +509,13 @@ ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate)
}
/* Explain each query */
foreach(l, query_list)
forboth (q, query_list, p, plan_list)
{
Query *query = (Query *) lfirst(l);
Plan *plan = (Plan *) lfirst(plan_list);
Query *query = (Query *) lfirst(q);
Plan *plan = (Plan *) lfirst(p);
bool is_last_query;
plan_list = lnext(plan_list);
is_last_query = (plan_list == NIL);
is_last_query = (lnext(p) == NULL);
if (query->commandType == CMD_UTILITY)
{
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.17 2003/11/29 19:51:47 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.18 2004/05/26 04:41:11 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -42,7 +42,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt)
const char *authId = stmt->authid;
Oid namespaceId;
List *parsetree_list;
List *parsetree_item;
ListCell *parsetree_item;
const char *owner_name;
AclId owner_userid;
AclId saved_userid;
......@@ -129,8 +129,8 @@ CreateSchemaCommand(CreateSchemaStmt *stmt)
foreach(parsetree_item, parsetree_list)
{
Node *parsetree = (Node *) lfirst(parsetree_item);
List *querytree_list,
*querytree_item;
List *querytree_list;
ListCell *querytree_item;
querytree_list = parse_analyze(parsetree, NULL, 0);
......@@ -166,11 +166,11 @@ RemoveSchema(List *names, DropBehavior behavior)
Oid namespaceId;
ObjectAddress object;
if (length(names) != 1)
if (list_length(names) != 1)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("schema name may not be qualified")));
namespaceName = strVal(lfirst(names));
namespaceName = strVal(linitial(names));
namespaceId = GetSysCacheOid(NAMESPACENAME,
CStringGetDatum(namespaceName),
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.110 2004/05/08 19:09:24 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.111 2004/05/26 04:41:11 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -862,7 +862,7 @@ init_params(List *options, Form_pg_sequence new, bool isInit)
DefElem *min_value = NULL;
DefElem *cache_value = NULL;
DefElem *is_cycled = NULL;
List *option;
ListCell *option;
foreach(option, options)
{
......
This diff is collapsed.
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.164 2004/02/10 01:55:25 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.165 2004/05/26 04:41:12 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -111,19 +111,19 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
bool needconstrrelid = false;
void *elem = NULL;
if (strncmp(strVal(llast(stmt->funcname)), "RI_FKey_check_", 14) == 0)
if (strncmp(strVal(lfirst(list_tail((stmt->funcname)))), "RI_FKey_check_", 14) == 0)
{
/* A trigger on FK table. */
needconstrrelid = true;
if (length(stmt->args) > RI_PK_RELNAME_ARGNO)
elem = nth(RI_PK_RELNAME_ARGNO, stmt->args);
if (list_length(stmt->args) > RI_PK_RELNAME_ARGNO)
elem = list_nth(stmt->args, RI_PK_RELNAME_ARGNO);
}
else if (strncmp(strVal(llast(stmt->funcname)), "RI_FKey_", 8) == 0)
else if (strncmp(strVal(lfirst(list_tail((stmt->funcname)))), "RI_FKey_", 8) == 0)
{
/* A trigger on PK table. */
needconstrrelid = true;
if (length(stmt->args) > RI_FK_RELNAME_ARGNO)
elem = nth(RI_FK_RELNAME_ARGNO, stmt->args);
if (list_length(stmt->args) > RI_FK_RELNAME_ARGNO)
elem = list_nth(stmt->args, RI_FK_RELNAME_ARGNO);
}
if (elem != NULL)
{
......@@ -318,9 +318,9 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
if (stmt->args)
{
List *le;
ListCell *le;
char *args;
int16 nargs = length(stmt->args);
int16 nargs = list_length(stmt->args);
int len = 0;
foreach(le, stmt->args)
......@@ -1691,7 +1691,7 @@ static bool
deferredTriggerCheckState(Oid tgoid, int32 itemstate)
{
MemoryContext oldcxt;
List *sl;
ListCell *sl;
DeferredTriggerStatus trigstate;
/*
......@@ -2193,7 +2193,7 @@ DeferredTriggerAbortXact(void)
void
DeferredTriggerSetState(ConstraintsSetStmt *stmt)
{
List *l;
ListCell *l;
/*
* Ignore call if we aren't in a transaction.
......@@ -2210,15 +2210,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
* Drop all per-transaction information about individual trigger
* states.
*/
l = deferredTriggers->deftrig_trigstates;
while (l != NIL)
{
List *next = lnext(l);
pfree(lfirst(l));
pfree(l);
l = next;
}
list_free_deep(deferredTriggers->deftrig_trigstates);
deferredTriggers->deftrig_trigstates = NIL;
/*
......@@ -2233,7 +2225,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
MemoryContext oldcxt;
bool found;
DeferredTriggerStatus state;
List *ls;
ListCell *ls;
List *loid = NIL;
/* ----------
......@@ -2293,7 +2285,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
cname)));
constr_oid = HeapTupleGetOid(htup);
loid = lappendo(loid, constr_oid);
loid = lappend_oid(loid, constr_oid);
found = true;
}
......@@ -2321,7 +2313,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
foreach(ls, deferredTriggers->deftrig_trigstates)
{
state = (DeferredTriggerStatus) lfirst(ls);
if (state->dts_tgoid == lfirsto(l))
if (state->dts_tgoid == lfirst_oid(l))
{
state->dts_tgisdeferred = stmt->deferred;
found = true;
......@@ -2332,7 +2324,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
{
state = (DeferredTriggerStatus)
palloc(sizeof(DeferredTriggerStatusData));
state->dts_tgoid = lfirsto(l);
state->dts_tgoid = lfirst_oid(l);
state->dts_tgisdeferred = stmt->deferred;
deferredTriggers->deftrig_trigstates =
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.56 2004/05/14 16:11:25 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.57 2004/05/26 04:41:12 neilc Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
......@@ -114,7 +114,7 @@ DefineType(List *names, List *parameters)
Oid sendOid = InvalidOid;
Oid analyzeOid = InvalidOid;
char *shadow_type;
List *pl;
ListCell *pl;
Oid typoid;
Oid resulttype;
......@@ -502,10 +502,10 @@ DefineDomain(CreateDomainStmt *stmt)
bool typNotNull = false;
bool nullDefined = false;
Oid basetypelem;
int32 typNDims = length(stmt->typename->arrayBounds);
int32 typNDims = list_length(stmt->typename->arrayBounds);
HeapTuple typeTup;
List *schema = stmt->constraints;
List *listptr;
ListCell *listptr;
Oid basetypeoid;
Oid domainoid;
Form_pg_type baseType;
......@@ -1304,7 +1304,7 @@ AlterDomainNotNull(List *names, bool notNull)
if (notNull)
{
List *rels;
List *rt;
ListCell *rt;
/* Fetch relation list with attributes based on this domain */
/* ShareLock is sufficient to prevent concurrent data changes */
......@@ -1461,7 +1461,7 @@ AlterDomainAddConstraint(List *names, Node *newConstraint)
HeapTuple tup;
Form_pg_type typTup;
List *rels;
List *rt;
ListCell *rt;
EState *estate;
ExprContext *econtext;
char *ccbin;
......@@ -1681,7 +1681,7 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
{
Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup);
RelToCheck *rtc = NULL;
List *rellist;
ListCell *rellist;
Form_pg_attribute pg_att;
int ptr;
......@@ -1848,7 +1848,7 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
/*
* Make sure no outside relations are referred to.
*/
if (length(pstate->p_rtable) != 0)
if (list_length(pstate->p_rtable) != 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("cannot use table references in domain check constraint")));
......
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.140 2004/05/06 16:59:16 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.141 2004/05/26 04:41:12 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -491,8 +491,8 @@ CreateUser(CreateUserStmt *stmt)
sysid_exists = false,
havesysid = false;
int max_id;
List *item,
*option;
ListCell *item;
ListCell *option;
char *password = NULL; /* PostgreSQL user password */
bool encrypt_password = Password_encryption; /* encrypt password? */
char encrypted_password[MD5_PASSWD_LEN + 1];
......@@ -715,7 +715,7 @@ CreateUser(CreateUserStmt *stmt)
ags.name = strVal(lfirst(item)); /* the group name to add
* this in */
ags.action = +1;
ags.listUsers = makeList1(makeInteger(sysid));
ags.listUsers = list_make1(makeInteger(sysid));
AlterGroup(&ags, "CREATE USER");
}
......@@ -746,7 +746,7 @@ AlterUser(AlterUserStmt *stmt)
TupleDesc pg_shadow_dsc;
HeapTuple tuple,
new_tuple;
List *option;
ListCell *option;
char *password = NULL; /* PostgreSQL user password */
bool encrypt_password = Password_encryption; /* encrypt password? */
char encrypted_password[MD5_PASSWD_LEN + 1];
......@@ -1017,7 +1017,7 @@ DropUser(DropUserStmt *stmt)
{
Relation pg_shadow_rel;
TupleDesc pg_shadow_dsc;
List *item;
ListCell *item;
if (!superuser())
ereport(ERROR,
......@@ -1122,7 +1122,7 @@ DropUser(DropUserStmt *stmt)
/* the group name from which to try to drop the user: */
ags.name = pstrdup(NameStr(((Form_pg_group) GETSTRUCT(tmp_tuple))->groname));
ags.action = -1;
ags.listUsers = makeList1(makeInteger(usesysid));
ags.listUsers = list_make1(makeInteger(usesysid));
AlterGroup(&ags, "DROP USER");
}
heap_endscan(scan);
......@@ -1283,9 +1283,9 @@ CreateGroup(CreateGroupStmt *stmt)
int max_id;
Datum new_record[Natts_pg_group];
char new_record_nulls[Natts_pg_group];
List *item,
*option,
*newlist = NIL;
ListCell *item;
ListCell *option;
List *newlist = NIL;
IdList *grolist;
int sysid = 0;
List *userElts = NIL;
......@@ -1397,8 +1397,8 @@ CreateGroup(CreateGroupStmt *stmt)
const char *groupuser = strVal(lfirst(item));
int32 userid = get_usesysid(groupuser);
if (!intMember(userid, newlist))
newlist = lappendi(newlist, userid);
if (!list_member_int(newlist, userid))
newlist = lappend_int(newlist, userid);
}
/* build an array to insert */
......@@ -1454,8 +1454,8 @@ AlterGroup(AlterGroupStmt *stmt, const char *tag)
IdList *oldarray;
Datum datum;
bool null;
List *newlist,
*item;
List *newlist;
ListCell *item;
/*
* Make sure the user can do this.
......@@ -1525,8 +1525,8 @@ AlterGroup(AlterGroupStmt *stmt, const char *tag)
sysid = 0; /* keep compiler quiet */
}
if (!intMember(sysid, newlist))
newlist = lappendi(newlist, sysid);
if (!list_member_int(newlist, sysid))
newlist = lappend_int(newlist, sysid);
}
/* Do the update */
......@@ -1565,8 +1565,8 @@ AlterGroup(AlterGroupStmt *stmt, const char *tag)
/* for dropuser we already know the uid */
sysid = intVal(lfirst(item));
}
if (intMember(sysid, newlist))
newlist = lremovei(sysid, newlist);
if (list_member_int(newlist, sysid))
newlist = list_delete_int(newlist, sysid);
else if (!is_dropuser)
ereport(WARNING,
(errcode(ERRCODE_WARNING),
......@@ -1636,9 +1636,9 @@ UpdateGroupMembership(Relation group_rel, HeapTuple group_tuple,
static IdList *
IdListToArray(List *members)
{
int nmembers = length(members);
int nmembers = list_length(members);
IdList *newarray;
List *item;
ListCell *item;
int i;
newarray = palloc(ARR_OVERHEAD(1) + nmembers * sizeof(int32));
......@@ -1650,7 +1650,7 @@ IdListToArray(List *members)
ARR_DIMS(newarray)[0] = nmembers; /* axis is this long */
i = 0;
foreach(item, members)
((int *) ARR_DATA_PTR(newarray))[i++] = lfirsti(item);
((int *) ARR_DATA_PTR(newarray))[i++] = lfirst_int(item);
return newarray;
}
......@@ -1679,8 +1679,8 @@ IdArrayToList(IdList *oldarray)
sysid = ((int32 *) ARR_DATA_PTR(oldarray))[i];
/* filter out any duplicates --- probably a waste of time */
if (!intMember(sysid, newlist))
newlist = lappendi(newlist, sysid);
if (!list_member_int(newlist, sysid))
newlist = lappend_int(newlist, sysid);
}
return newlist;
......
......@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.277 2004/05/22 23:14:38 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.278 2004/05/26 04:41:12 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -164,8 +164,8 @@ vacuum(VacuumStmt *vacstmt)
bool all_rels,
in_outer_xact,
use_own_xacts;
List *relations,
*cur;
List *relations;
ListCell *cur;
if (vacstmt->verbose)
elevel = INFO;
......@@ -276,7 +276,7 @@ vacuum(VacuumStmt *vacstmt)
Assert(vacstmt->analyze);
if (in_outer_xact)
use_own_xacts = false;
else if (length(relations) > 1)
else if (list_length(relations) > 1)
use_own_xacts = true;
else
use_own_xacts = false;
......@@ -312,7 +312,7 @@ vacuum(VacuumStmt *vacstmt)
*/
foreach(cur, relations)
{
Oid relid = lfirsto(cur);
Oid relid = lfirst_oid(cur);
if (vacstmt->vacuum)
{
......@@ -431,7 +431,7 @@ get_rel_oids(const RangeVar *vacrel, const char *stmttype)
/* Make a relation list entry for this guy */
oldcontext = MemoryContextSwitchTo(vac_context);
oid_list = lappendo(oid_list, relid);
oid_list = lappend_oid(oid_list, relid);
MemoryContextSwitchTo(oldcontext);
}
else
......@@ -455,7 +455,7 @@ get_rel_oids(const RangeVar *vacrel, const char *stmttype)
{
/* Make a relation list entry for this guy */
oldcontext = MemoryContextSwitchTo(vac_context);
oid_list = lappendo(oid_list, HeapTupleGetOid(tuple));
oid_list = lappend_oid(oid_list, HeapTupleGetOid(tuple));
MemoryContextSwitchTo(oldcontext);
}
......@@ -3061,13 +3061,13 @@ vac_cmp_vtlinks(const void *left, const void *right)
void
vac_open_indexes(Relation relation, int *nindexes, Relation **Irel)
{
List *indexoidlist,
*indexoidscan;
List *indexoidlist;
ListCell *indexoidscan;
int i;
indexoidlist = RelationGetIndexList(relation);
*nindexes = length(indexoidlist);
*nindexes = list_length(indexoidlist);
if (*nindexes > 0)
*Irel = (Relation *) palloc(*nindexes * sizeof(Relation));
......@@ -3077,13 +3077,13 @@ vac_open_indexes(Relation relation, int *nindexes, Relation **Irel)
i = 0;
foreach(indexoidscan, indexoidlist)
{
Oid indexoid = lfirsto(indexoidscan);
Oid indexoid = lfirst_oid(indexoidscan);
(*Irel)[i] = index_open(indexoid);
i++;
}
freeList(indexoidlist);
list_free(indexoidlist);
}
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.96 2004/05/23 23:12:11 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.97 2004/05/26 04:41:13 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -48,7 +48,7 @@ assign_datestyle(const char *value, bool doit, GucSource source)
char *rawstring;
char *result;
List *elemlist;
List *l;
ListCell *l;
/* Need a modifiable copy of string */
rawstring = pstrdup(value);
......@@ -58,7 +58,7 @@ assign_datestyle(const char *value, bool doit, GucSource source)
{
/* syntax error in list */
pfree(rawstring);
freeList(elemlist);
list_free(elemlist);
if (source >= PGC_S_INTERACTIVE)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
......@@ -159,7 +159,7 @@ assign_datestyle(const char *value, bool doit, GucSource source)
ok = false;
pfree(rawstring);
freeList(elemlist);
list_free(elemlist);
if (!ok)
{
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.81 2004/01/14 23:01:54 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.82 2004/05/26 04:41:13 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -47,8 +47,8 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace)
Oid viewOid,
namespaceId;
CreateStmt *createStmt = makeNode(CreateStmt);
List *attrList,
*t;
List *attrList;
ListCell *t;
/*
* create a list of ColumnDef nodes based on the names and types of
......@@ -217,7 +217,7 @@ FormViewRetrieveRule(const RangeVar *view, Query *viewParse, bool replace)
rule->whereClause = NULL;
rule->event = CMD_SELECT;
rule->instead = true;
rule->actions = makeList1(viewParse);
rule->actions = list_make1(viewParse);
rule->replace = replace;
return rule;
......
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.78 2004/03/02 18:56:15 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.79 2004/05/26 04:41:14 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -64,11 +64,11 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
/* If we have changed parameters, propagate that info */
if (node->chgParam != NULL)
{
List *lst;
ListCell *l;
foreach(lst, node->initPlan)
foreach(l, node->initPlan)
{
SubPlanState *sstate = (SubPlanState *) lfirst(lst);
SubPlanState *sstate = (SubPlanState *) lfirst(l);
PlanState *splan = sstate->planstate;
if (splan->plan->extParam != NULL) /* don't care about child
......@@ -77,9 +77,9 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
if (splan->chgParam != NULL)
ExecReScanSetParamPlan(sstate, node);
}
foreach(lst, node->subPlan)
foreach(l, node->subPlan)
{
SubPlanState *sstate = (SubPlanState *) lfirst(lst);
SubPlanState *sstate = (SubPlanState *) lfirst(l);
PlanState *splan = sstate->planstate;
if (splan->plan->extParam != NULL)
......@@ -315,7 +315,7 @@ ExecSupportsBackwardScan(Plan *node)
case T_Append:
{
List *l;
ListCell *l;
foreach(l, ((Append *) node)->appendplans)
{
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execJunk.c,v 1.39 2004/04/07 18:46:12 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execJunk.c,v 1.40 2004/05/26 04:41:14 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -68,7 +68,7 @@ ExecInitJunkFilter(List *targetList, TupleDesc tupType,
int len,
cleanLength;
TupleDesc cleanTupType;
List *t;
ListCell *t;
TargetEntry *tle;
Resdom *resdom,
*cleanResdom;
......@@ -184,7 +184,7 @@ ExecGetJunkAttribute(JunkFilter *junkfilter,
bool *isNull)
{
List *targetList;
List *t;
ListCell *t;
AttrNumber resno;
TupleDesc tupType;
HeapTuple tuple;
......
......@@ -26,7 +26,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.231 2004/05/11 17:36:12 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.232 2004/05/26 04:41:14 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -353,11 +353,11 @@ ExecutorRewind(QueryDesc *queryDesc)
void
ExecCheckRTPerms(List *rangeTable)
{
List *lp;
ListCell *l;
foreach(lp, rangeTable)
foreach(l, rangeTable)
{
RangeTblEntry *rte = lfirst(lp);
RangeTblEntry *rte = lfirst(l);
ExecCheckRTEPerms(rte);
}
......@@ -427,7 +427,7 @@ ExecCheckRTEPerms(RangeTblEntry *rte)
static void
ExecCheckXactReadOnly(Query *parsetree)
{
List *lp;
ListCell *l;
/*
* CREATE TABLE AS or SELECT INTO?
......@@ -438,9 +438,9 @@ ExecCheckXactReadOnly(Query *parsetree)
goto fail;
/* Fail if write permissions are requested on any non-temp table */
foreach(lp, parsetree->rtable)
foreach(l, parsetree->rtable)
{
RangeTblEntry *rte = lfirst(lp);
RangeTblEntry *rte = lfirst(l);
if (rte->rtekind == RTE_SUBQUERY)
{
......@@ -522,19 +522,19 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
* parseTree->resultRelations identifies them all
*/
ResultRelInfo *resultRelInfo;
ListCell *l;
numResultRelations = length(resultRelations);
resultRelInfos = (ResultRelInfo *)
palloc(numResultRelations * sizeof(ResultRelInfo));
resultRelInfo = resultRelInfos;
while (resultRelations != NIL)
foreach(l, resultRelations)
{
initResultRelInfo(resultRelInfo,
lfirsti(resultRelations),
lfirst_int(l),
rangeTable,
operation);
resultRelInfo++;
resultRelations = lnext(resultRelations);
}
}
else
......@@ -586,7 +586,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
estate->es_rowMark = NIL;
if (parseTree->rowMarks != NIL)
{
List *l;
ListCell *l;
foreach(l, parseTree->rowMarks)
{
......@@ -651,7 +651,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
*/
{
bool junk_filter_needed = false;
List *tlist;
ListCell *tlist;
switch (operation)
{
......@@ -950,7 +950,7 @@ ExecEndPlan(PlanState *planstate, EState *estate)
{
ResultRelInfo *resultRelInfo;
int i;
List *l;
ListCell *l;
/*
* shut down any PlanQual processing we were doing
......@@ -1132,7 +1132,7 @@ lnext: ;
}
else if (estate->es_rowMark != NIL)
{
List *l;
ListCell *l;
lmark: ;
foreach(l, estate->es_rowMark)
......@@ -1785,7 +1785,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
relation = estate->es_result_relation_info->ri_RelationDesc;
else
{
List *l;
ListCell *l;
relation = NULL;
foreach(l, estate->es_rowMark)
......
......@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execProcnode.c,v 1.42 2004/03/02 22:17:34 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execProcnode.c,v 1.43 2004/05/26 04:41:15 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -119,7 +119,7 @@ ExecInitNode(Plan *node, EState *estate)
{
PlanState *result;
List *subps;
List *subp;
ListCell *l;
/*
* do nothing when we get to the end of a leaf on tree.
......@@ -224,9 +224,9 @@ ExecInitNode(Plan *node, EState *estate)
* them in a separate list for us.
*/
subps = NIL;
foreach(subp, node->initPlan)
foreach(l, node->initPlan)
{
SubPlan *subplan = (SubPlan *) lfirst(subp);
SubPlan *subplan = (SubPlan *) lfirst(l);
SubPlanState *sstate;
Assert(IsA(subplan, SubPlan));
......@@ -242,9 +242,9 @@ ExecInitNode(Plan *node, EState *estate)
* do this after initializing initPlans, in case their arguments
* contain subPlans (is that actually possible? perhaps not).
*/
foreach(subp, result->subPlan)
foreach(l, result->subPlan)
{
SubPlanState *sstate = (SubPlanState *) lfirst(subp);
SubPlanState *sstate = (SubPlanState *) lfirst(l);
Assert(IsA(sstate, SubPlanState));
ExecInitSubPlan(sstate, estate);
......@@ -483,7 +483,7 @@ ExecCountSlotsNode(Plan *node)
void
ExecEndNode(PlanState *node)
{
List *subp;
ListCell *subp;
/*
* do nothing when we get to the end of a leaf on tree.
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.159 2004/05/10 22:44:43 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.160 2004/05/26 04:41:15 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -217,7 +217,7 @@ ExecEvalArrayRef(ArrayRefExprState *astate,
ArrayType *array_source;
ArrayType *resultArray;
bool isAssignment = (arrayRef->refassgnexpr != NULL);
List *elt;
ListCell *l;
int i = 0,
j = 0;
IntArray upper,
......@@ -258,9 +258,9 @@ ExecEvalArrayRef(ArrayRefExprState *astate,
array_source = NULL;
}
foreach(elt, astate->refupperindexpr)
foreach(l, astate->refupperindexpr)
{
ExprState *eltstate = (ExprState *) lfirst(elt);
ExprState *eltstate = (ExprState *) lfirst(l);
if (i >= MAXDIM)
ereport(ERROR,
......@@ -284,9 +284,9 @@ ExecEvalArrayRef(ArrayRefExprState *astate,
if (astate->reflowerindexpr != NIL)
{
foreach(elt, astate->reflowerindexpr)
foreach(l, astate->reflowerindexpr)
{
ExprState *eltstate = (ExprState *) lfirst(elt);
ExprState *eltstate = (ExprState *) lfirst(l);
if (j >= MAXDIM)
ereport(ERROR,
......@@ -798,7 +798,7 @@ ExecEvalFuncArgs(FunctionCallInfo fcinfo,
{
ExprDoneCond argIsDone;
int i;
List *arg;
ListCell *arg;
argIsDone = ExprSingleResult; /* default assumption */
......@@ -1070,7 +1070,7 @@ ExecMakeFunctionResultNoSets(FuncExprState *fcache,
bool *isNull,
ExprDoneCond *isDone)
{
List *arg;
ListCell *arg;
Datum result;
FunctionCallInfoData fcinfo;
int i;
......@@ -1703,7 +1703,7 @@ static Datum
ExecEvalNot(BoolExprState *notclause, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone)
{
ExprState *clause = lfirst(notclause->args);
ExprState *clause = linitial(notclause->args);
Datum expr_value;
if (isDone)
......@@ -1734,7 +1734,7 @@ ExecEvalOr(BoolExprState *orExpr, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone)
{
List *clauses = orExpr->args;
List *clause;
ListCell *clause;
bool AnyNull;
if (isDone)
......@@ -1786,7 +1786,7 @@ ExecEvalAnd(BoolExprState *andExpr, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone)
{
List *clauses = andExpr->args;
List *clause;
ListCell *clause;
bool AnyNull;
if (isDone)
......@@ -1802,6 +1802,7 @@ ExecEvalAnd(BoolExprState *andExpr, ExprContext *econtext,
* when you interpret NULL as "don't know", using the same sort of
* reasoning as for OR, above.
*/
foreach(clause, clauses)
{
ExprState *clausestate = (ExprState *) lfirst(clause);
......@@ -1838,7 +1839,7 @@ ExecEvalCase(CaseExprState *caseExpr, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone)
{
List *clauses = caseExpr->args;
List *clause;
ListCell *clause;
Datum save_datum;
bool save_isNull;
......@@ -1938,7 +1939,7 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext,
{
ArrayExpr *arrayExpr = (ArrayExpr *) astate->xprstate.expr;
ArrayType *result;
List *element;
ListCell *element;
Oid element_type = arrayExpr->element_typeid;
int ndims = 0;
int dims[MAXDIM];
......@@ -2118,7 +2119,7 @@ ExecEvalRow(RowExprState *rstate,
Datum *values;
char *nulls;
int nargs;
List *arg;
ListCell *arg;
int i;
/* Set default values for result flags: non-null, not a set result */
......@@ -2161,7 +2162,7 @@ static Datum
ExecEvalCoalesce(CoalesceExprState *coalesceExpr, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone)
{
List *arg;
ListCell *arg;
if (isDone)
*isDone = ExprSingleResult;
......@@ -2390,7 +2391,7 @@ ExecEvalCoerceToDomain(CoerceToDomainState *cstate, ExprContext *econtext,
{
CoerceToDomain *ctest = (CoerceToDomain *) cstate->xprstate.expr;
Datum result;
List *l;
ListCell *l;
result = ExecEvalExpr(cstate->arg, econtext, isNull, isDone);
......@@ -2826,14 +2827,14 @@ ExecInitExpr(Expr *node, PlanState *parent)
CaseExpr *caseexpr = (CaseExpr *) node;
CaseExprState *cstate = makeNode(CaseExprState);
FastList outlist;
List *inlist;
ListCell *l;
cstate->xprstate.evalfunc = (ExprStateEvalFunc) ExecEvalCase;
cstate->arg = ExecInitExpr(caseexpr->arg, parent);
FastListInit(&outlist);
foreach(inlist, caseexpr->args)
foreach(l, caseexpr->args)
{
CaseWhen *when = (CaseWhen *) lfirst(inlist);
CaseWhen *when = (CaseWhen *) lfirst(l);
CaseWhenState *wstate = makeNode(CaseWhenState);
Assert(IsA(when, CaseWhen));
......@@ -2853,13 +2854,13 @@ ExecInitExpr(Expr *node, PlanState *parent)
ArrayExpr *arrayexpr = (ArrayExpr *) node;
ArrayExprState *astate = makeNode(ArrayExprState);
FastList outlist;
List *inlist;
ListCell *l;
astate->xprstate.evalfunc = (ExprStateEvalFunc) ExecEvalArray;
FastListInit(&outlist);
foreach(inlist, arrayexpr->elements)
foreach(l, arrayexpr->elements)
{
Expr *e = (Expr *) lfirst(inlist);
Expr *e = (Expr *) lfirst(l);
ExprState *estate;
estate = ExecInitExpr(e, parent);
......@@ -2879,13 +2880,13 @@ ExecInitExpr(Expr *node, PlanState *parent)
RowExpr *rowexpr = (RowExpr *) node;
RowExprState *rstate = makeNode(RowExprState);
List *outlist;
List *inlist;
ListCell *l;
rstate->xprstate.evalfunc = (ExprStateEvalFunc) ExecEvalRow;
outlist = NIL;
foreach(inlist, rowexpr->args)
foreach(l, rowexpr->args)
{
Expr *e = (Expr *) lfirst(inlist);
Expr *e = (Expr *) lfirst(l);
ExprState *estate;
estate = ExecInitExpr(e, parent);
......@@ -2912,13 +2913,13 @@ ExecInitExpr(Expr *node, PlanState *parent)
CoalesceExpr *coalesceexpr = (CoalesceExpr *) node;
CoalesceExprState *cstate = makeNode(CoalesceExprState);
FastList outlist;
List *inlist;
ListCell *l;
cstate->xprstate.evalfunc = (ExprStateEvalFunc) ExecEvalCoalesce;
FastListInit(&outlist);
foreach(inlist, coalesceexpr->args)
foreach(l, coalesceexpr->args)
{
Expr *e = (Expr *) lfirst(inlist);
Expr *e = (Expr *) lfirst(l);
ExprState *estate;
estate = ExecInitExpr(e, parent);
......@@ -2984,13 +2985,13 @@ ExecInitExpr(Expr *node, PlanState *parent)
case T_List:
{
FastList outlist;
List *inlist;
ListCell *l;
FastListInit(&outlist);
foreach(inlist, (List *) node)
foreach(l, (List *) node)
{
FastAppend(&outlist,
ExecInitExpr((Expr *) lfirst(inlist),
ExecInitExpr((Expr *) lfirst(l),
parent));
}
/* Don't fall through to the "common" code below */
......@@ -3101,7 +3102,7 @@ ExecQual(List *qual, ExprContext *econtext, bool resultForNull)
{
bool result;
MemoryContext oldContext;
List *qlist;
ListCell *l;
/*
* debugging stuff
......@@ -3131,9 +3132,9 @@ ExecQual(List *qual, ExprContext *econtext, bool resultForNull)
*/
result = true;
foreach(qlist, qual)
foreach(l, qual)
{
ExprState *clause = (ExprState *) lfirst(qlist);
ExprState *clause = (ExprState *) lfirst(l);
Datum expr_value;
bool isNull;
......@@ -3179,7 +3180,7 @@ int
ExecCleanTargetListLength(List *targetlist)
{
int len = 0;
List *tl;
ListCell *tl;
foreach(tl, targetlist)
{
......@@ -3219,7 +3220,7 @@ ExecTargetList(List *targetlist,
ExprDoneCond *isDone)
{
MemoryContext oldContext;
List *tl;
ListCell *tl;
bool isNull;
bool haveDoneSets;
......
......@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execScan.c,v 1.30 2004/01/22 02:23:21 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execScan.c,v 1.31 2004/05/26 04:41:15 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -195,6 +195,7 @@ tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc
int numattrs = tupdesc->natts;
int attrno;
bool hasoid;
ListCell *tlist_item = list_head(tlist);
/* Check the tlist attributes */
for (attrno = 1; attrno <= numattrs; attrno++)
......@@ -202,9 +203,9 @@ tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc
Form_pg_attribute att_tup = tupdesc->attrs[attrno - 1];
Var *var;
if (tlist == NIL)
if (tlist_item == NULL)
return false; /* tlist too short */
var = (Var *) ((TargetEntry *) lfirst(tlist))->expr;
var = (Var *) ((TargetEntry *) lfirst(tlist_item))->expr;
if (!var || !IsA(var, Var))
return false; /* tlist item not a Var */
Assert(var->varno == varno);
......@@ -216,10 +217,10 @@ tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc
Assert(var->vartype == att_tup->atttypid);
Assert(var->vartypmod == att_tup->atttypmod);
tlist = lnext(tlist);
tlist_item = lnext(tlist_item);
}
if (tlist)
if (tlist_item)
return false; /* tlist too long */
/*
......
......@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.77 2004/05/10 22:44:44 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.78 2004/05/26 04:41:15 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -569,7 +569,7 @@ static TupleDesc
ExecTypeFromTLInternal(List *targetList, bool hasoid, bool skipjunk)
{
TupleDesc typeInfo;
List *l;
ListCell *l;
int len;
int cur_resno = 1;
......@@ -606,7 +606,7 @@ TupleDesc
ExecTypeFromExprList(List *exprList)
{
TupleDesc typeInfo;
List *l;
ListCell *l;
int cur_resno = 1;
char fldname[NAMEDATALEN];
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.110 2004/03/17 20:48:42 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.111 2004/05/26 04:41:15 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -248,7 +248,10 @@ FreeExecutorState(EState *estate)
*/
while (estate->es_exprcontexts)
{
FreeExprContext((ExprContext *) lfirst(estate->es_exprcontexts));
/* XXX: seems there ought to be a faster way to implement this
* than repeated lremove(), no?
*/
FreeExprContext((ExprContext *) linitial(estate->es_exprcontexts));
/* FreeExprContext removed the list link for us */
}
......@@ -636,8 +639,8 @@ void
ExecOpenIndices(ResultRelInfo *resultRelInfo)
{
Relation resultRelation = resultRelInfo->ri_RelationDesc;
List *indexoidlist,
*indexoidscan;
List *indexoidlist;
ListCell *l;
int len,
i;
RelationPtr relationDescs;
......@@ -671,9 +674,9 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo)
* For each index, open the index relation and save pg_index info.
*/
i = 0;
foreach(indexoidscan, indexoidlist)
foreach(l, indexoidlist)
{
Oid indexOid = lfirsto(indexoidscan);
Oid indexOid = lfirsto(l);
Relation indexDesc;
IndexInfo *ii;
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.80 2004/04/02 23:14:08 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.81 2004/05/26 04:41:15 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -92,7 +92,7 @@ init_execution_state(List *queryTree_list)
{
execution_state *firstes = NULL;
execution_state *preves = NULL;
List *qtl_item;
ListCell *qtl_item;
foreach(qtl_item, queryTree_list)
{
......
......@@ -45,7 +45,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.119 2004/03/13 00:54:10 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.120 2004/05/26 04:41:15 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -1033,7 +1033,7 @@ ExecInitAgg(Agg *node, EState *estate)
ExprContext *econtext;
int numaggs,
aggno;
List *alist;
ListCell *l;
/*
* create state structure
......@@ -1187,9 +1187,9 @@ ExecInitAgg(Agg *node, EState *estate)
* result entry by giving them duplicate aggno values.
*/
aggno = -1;
foreach(alist, aggstate->aggs)
foreach(l, aggstate->aggs)
{
AggrefExprState *aggrefstate = (AggrefExprState *) lfirst(alist);
AggrefExprState *aggrefstate = (AggrefExprState *) lfirst(l);
Aggref *aggref = (Aggref *) aggrefstate->xprstate.expr;
AggStatePerAgg peraggstate;
Oid inputType;
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeAppend.c,v 1.56 2004/01/22 02:23:21 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeAppend.c,v 1.57 2004/05/26 04:41:15 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -237,7 +237,7 @@ ExecInitAppend(Append *node, EState *estate)
int
ExecCountSlotsAppend(Append *node)
{
List *plan;
ListCell *plan;
int nSlots = 0;
foreach(plan, node->appendplans)
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeFunctionscan.c,v 1.24 2004/04/01 21:28:44 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeFunctionscan.c,v 1.25 2004/05/26 04:41:15 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -201,7 +201,7 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate)
else if (functyptype == 'b' || functyptype == 'd')
{
/* Must be a base data type, i.e. scalar */
char *attname = strVal(lfirst(rte->eref->colnames));
char *attname = strVal(linitial(rte->eref->colnames));
tupdesc = CreateTemplateTupleDesc(1, false);
TupleDescInitEntry(tupdesc,
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.83 2004/03/17 01:02:23 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.84 2004/05/26 04:41:15 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -202,7 +202,7 @@ ExecHashTableCreate(Hash *node, List *hashOperators)
int nbatch;
int nkeys;
int i;
List *ho;
ListCell *ho;
MemoryContext oldcxt;
/*
......@@ -518,7 +518,7 @@ ExecHashGetBucket(HashJoinTable hashtable,
{
uint32 hashkey = 0;
int bucketno;
List *hk;
ListCell *hk;
int i = 0;
MemoryContext oldContext;
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.60 2004/01/07 18:56:26 neilc Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.61 2004/05/26 04:41:15 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -311,7 +311,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate)
List *lclauses;
List *rclauses;
List *hoperators;
List *hcl;
ListCell *l;
/*
* create state structure
......@@ -419,15 +419,15 @@ ExecInitHashJoin(HashJoin *node, EState *estate)
lclauses = NIL;
rclauses = NIL;
hoperators = NIL;
foreach(hcl, hjstate->hashclauses)
foreach(l, hjstate->hashclauses)
{
FuncExprState *fstate = (FuncExprState *) lfirst(hcl);
FuncExprState *fstate = (FuncExprState *) lfirst(l);
OpExpr *hclause;
Assert(IsA(fstate, FuncExprState));
hclause = (OpExpr *) fstate->xprstate.expr;
Assert(IsA(hclause, OpExpr));
lclauses = lappend(lclauses, lfirst(fstate->args));
lclauses = lappend(lclauses, linitial(fstate->args));
rclauses = lappend(rclauses, lsecond(fstate->args));
hoperators = lappendo(hoperators, hclause->opno);
}
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.93 2004/04/21 18:24:26 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.94 2004/05/26 04:41:16 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -146,7 +146,7 @@ IndexNext(IndexScanState *node)
if (estate->es_evTuple != NULL &&
estate->es_evTuple[scanrelid - 1] != NULL)
{
List *qual;
ListCell *qual;
if (estate->es_evTupleNull[scanrelid - 1])
return slot; /* return empty slot */
......@@ -164,7 +164,7 @@ IndexNext(IndexScanState *node)
if (ExecQual((List *) lfirst(qual), econtext, false))
break;
}
if (qual == NIL) /* would not be returned by indices */
if (qual == NULL) /* would not be returned by indices */
slot->val = NULL;
/* Flag for the next call that no more tuples */
......@@ -283,11 +283,11 @@ IndexNext(IndexScanState *node)
{
bool prev_matches = false;
int prev_index;
List *qual;
ListCell *qual;
econtext->ecxt_scantuple = slot;
ResetExprContext(econtext);
qual = node->indxqualorig;
qual = list_head(node->indxqualorig);
for (prev_index = 0;
prev_index < node->iss_IndexPtr;
prev_index++)
......@@ -641,11 +641,11 @@ IndexScanState *
ExecInitIndexScan(IndexScan *node, EState *estate)
{
IndexScanState *indexstate;
List *indxqual;
List *indxstrategy;
List *indxsubtype;
List *indxlossy;
List *indxid;
ListCell *indxqual;
ListCell *indxstrategy;
ListCell *indxsubtype;
ListCell *indxlossy;
ListCell *indxid_item;
int i;
int numIndices;
int indexPtr;
......@@ -719,8 +719,8 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
/*
* get the index node information
*/
indxid = node->indxid;
numIndices = length(indxid);
indxid_item = list_head(node->indxid);
numIndices = length(node->indxid);
indexPtr = -1;
CXT1_printf("ExecInitIndexScan: context is %d\n", CurrentMemoryContext);
......@@ -745,28 +745,32 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
/*
* build the index scan keys from the index qualification
*/
indxqual = node->indxqual;
indxstrategy = node->indxstrategy;
indxsubtype = node->indxsubtype;
indxlossy = node->indxlossy;
indxqual = list_head(node->indxqual);
indxstrategy = list_head(node->indxstrategy);
indxsubtype = list_head(node->indxsubtype);
indxlossy = list_head(node->indxlossy);
for (i = 0; i < numIndices; i++)
{
List *quals;
List *strategies;
List *subtypes;
List *lossyflags;
ListCell *qual_cell;
ListCell *strategy_cell;
ListCell *subtype_cell;
ListCell *lossyflag_cell;
int n_keys;
ScanKey scan_keys;
ExprState **run_keys;
int j;
quals = lfirst(indxqual);
quals = (List *) lfirst(indxqual);
indxqual = lnext(indxqual);
strategies = lfirst(indxstrategy);
strategies = (List *) lfirst(indxstrategy);
indxstrategy = lnext(indxstrategy);
subtypes = lfirst(indxsubtype);
subtypes = (List *) lfirst(indxsubtype);
indxsubtype = lnext(indxsubtype);
lossyflags = lfirst(indxlossy);
lossyflags = (List *) lfirst(indxlossy);
indxlossy = lnext(indxlossy);
n_keys = length(quals);
scan_keys = (n_keys <= 0) ? NULL :
......@@ -778,6 +782,10 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
* for each opclause in the given qual, convert each qual's
* opclause into a single scan key
*/
qual_cell = list_head(quals);
strategy_cell = list_head(strategies);
subtype_cell = list_head(subtypes);
lossyflag_cell = list_head(lossyflags);
for (j = 0; j < n_keys; j++)
{
OpExpr *clause; /* one clause of index qual */
......@@ -794,14 +802,14 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
/*
* extract clause information from the qualification
*/
clause = (OpExpr *) lfirst(quals);
quals = lnext(quals);
strategy = lfirsti(strategies);
strategies = lnext(strategies);
subtype = lfirsto(subtypes);
subtypes = lnext(subtypes);
lossy = lfirsti(lossyflags);
lossyflags = lnext(lossyflags);
clause = (OpExpr *) lfirst(qual_cell);
qual_cell = lnext(qual_cell);
strategy = lfirsti(strategy_cell);
strategy_cell = lnext(strategy_cell);
subtype = lfirsto(subtype_cell);
subtype_cell = lnext(subtype_cell);
lossy = lfirsti(lossyflag_cell);
lossyflag_cell = lnext(lossyflag_cell);
if (!IsA(clause, OpExpr))
elog(ERROR, "indxqual is not an OpExpr");
......@@ -972,7 +980,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
*/
for (i = 0; i < numIndices; i++)
{
Oid indexOid = lfirsto(indxid);
Oid indexOid = lfirsto(indxid_item);
indexDescs[i] = index_open(indexOid);
scanDescs[i] = index_beginscan(currentRelation,
......@@ -980,7 +988,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
estate->es_snapshot,
numScanKeys[i],
scanKeys[i]);
indxid = lnext(indxid);
indxid_item = lnext(indxid_item);
}
indexstate->iss_RelationDescs = indexDescs;
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.64 2004/03/17 01:02:23 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.65 2004/05/26 04:41:16 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -105,8 +105,8 @@ MJFormSkipQuals(List *qualList, List **ltQuals, List **gtQuals,
PlanState *parent)
{
List *ltexprs,
*gtexprs,
*ltcdr,
*gtexprs;
ListCell *ltcdr,
*gtcdr;
/*
......@@ -119,8 +119,7 @@ MJFormSkipQuals(List *qualList, List **ltQuals, List **gtQuals,
* Scan both lists in parallel, so that we can update the operators
* with the minimum number of syscache searches.
*/
ltcdr = ltexprs;
foreach(gtcdr, gtexprs)
forboth(ltcdr, ltexprs, gtcdr, gtexprs)
{
OpExpr *ltop = (OpExpr *) lfirst(ltcdr);
OpExpr *gtop = (OpExpr *) lfirst(gtcdr);
......@@ -140,8 +139,6 @@ MJFormSkipQuals(List *qualList, List **ltQuals, List **gtQuals,
&gtop->opno,
&ltop->opfuncid,
&gtop->opfuncid);
ltcdr = lnext(ltcdr);
}
/*
......@@ -173,8 +170,8 @@ MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext)
{
bool result;
MemoryContext oldContext;
List *clause;
List *eqclause;
ListCell *clause;
ListCell *eqclause;
/*
* Do expression eval in short-lived context.
......@@ -188,8 +185,12 @@ MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext)
*/
result = false; /* assume 'false' result */
eqclause = eqQual;
foreach(clause, compareQual)
/*
* We can't run out of one list before the other
*/
Assert(length(compareQual) == length(eqQual));
forboth(clause, compareQual, eqclause, eqQual)
{
ExprState *clauseexpr = (ExprState *) lfirst(clause);
ExprState *eqclauseexpr = (ExprState *) lfirst(eqclause);
......@@ -220,8 +221,6 @@ MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext)
if (!DatumGetBool(const_value) || isNull)
break; /* return false */
eqclause = lnext(eqclause);
}
MemoryContextSwitchTo(oldContext);
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.61 2004/03/17 01:02:23 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.62 2004/05/26 04:41:16 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -212,8 +212,8 @@ ExecScanSubPlan(SubPlanState *node,
TupleTableSlot *slot;
Datum result;
bool found = false; /* TRUE if got at least one subplan tuple */
List *pvar;
List *lst;
ListCell *pvar;
ListCell *l;
ArrayBuildState *astate = NULL;
/*
......@@ -228,21 +228,19 @@ ExecScanSubPlan(SubPlanState *node,
* calculation we have to do is done in the parent econtext, since the
* Param values don't need to have per-query lifetime.)
*/
pvar = node->args;
foreach(lst, subplan->parParam)
Assert(length(subplan->parParam) == length(node->args));
forboth(l, subplan->parParam, pvar, node->args)
{
int paramid = lfirsti(lst);
int paramid = lfirst_int(l);
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
Assert(pvar != NIL);
prm->value = ExecEvalExprSwitchContext((ExprState *) lfirst(pvar),
econtext,
&(prm->isnull),
NULL);
pvar = lnext(pvar);
planstate->chgParam = bms_add_member(planstate->chgParam, paramid);
}
Assert(pvar == NIL);
ExecReScan(planstate, NULL);
......@@ -278,7 +276,7 @@ ExecScanSubPlan(SubPlanState *node,
Datum rowresult = BoolGetDatum(!useOr);
bool rownull = false;
int col = 1;
List *plst;
ListCell *plst;
if (subLinkType == EXISTS_SUBLINK)
{
......@@ -343,11 +341,12 @@ ExecScanSubPlan(SubPlanState *node,
* For ALL, ANY, and MULTIEXPR sublinks, iterate over combining
* operators for columns of tuple.
*/
plst = subplan->paramIds;
foreach(lst, node->exprs)
Assert(length(node->exprs) == length(subplan->paramIds));
forboth(l, node->exprs, plst, subplan->paramIds)
{
ExprState *exprstate = (ExprState *) lfirst(lst);
int paramid = lfirsti(plst);
ExprState *exprstate = (ExprState *) lfirst(l);
int paramid = lfirst_int(plst);
ParamExecData *prmdata;
Datum expresult;
bool expnull;
......@@ -400,7 +399,6 @@ ExecScanSubPlan(SubPlanState *node,
}
}
plst = lnext(plst);
col++;
}
......@@ -559,7 +557,7 @@ buildSubPlanHash(SubPlanState *node)
HeapTuple tup = slot->val;
TupleDesc tdesc = slot->ttc_tupleDescriptor;
int col = 1;
List *plst;
ListCell *plst;
bool isnew;
/*
......@@ -737,7 +735,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
*/
if (subplan->setParam != NIL)
{
List *lst;
ListCell *lst;
foreach(lst, subplan->setParam)
{
......@@ -762,8 +760,8 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
List *lefttlist,
*righttlist,
*leftptlist,
*rightptlist,
*lexpr;
*rightptlist;
ListCell *lexpr;
/* We need a memory context to hold the hash table(s) */
node->tablecxt =
......@@ -815,7 +813,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
Assert(length(fstate->args) == 2);
/* Process lefthand argument */
exstate = (ExprState *) lfirst(fstate->args);
exstate = (ExprState *) linitial(fstate->args);
expr = exstate->expr;
tle = makeTargetEntry(makeResdom(i,
exprType((Node *) expr),
......@@ -914,7 +912,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
SubLinkType subLinkType = subplan->subLinkType;
MemoryContext oldcontext;
TupleTableSlot *slot;
List *lst;
ListCell *l;
bool found = false;
ArrayBuildState *astate = NULL;
......@@ -941,7 +939,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
if (subLinkType == EXISTS_SUBLINK)
{
/* There can be only one param... */
int paramid = lfirsti(subplan->setParam);
int paramid = linitial_int(subplan->setParam);
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
prm->execPlan = NULL;
......@@ -992,9 +990,9 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
/*
* Now set all the setParam params from the columns of the tuple
*/
foreach(lst, subplan->setParam)
foreach(l, subplan->setParam)
{
int paramid = lfirsti(lst);
int paramid = lfirsti(l);
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
prm->execPlan = NULL;
......@@ -1008,7 +1006,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
if (subLinkType == EXISTS_SUBLINK)
{
/* There can be only one param... */
int paramid = lfirsti(subplan->setParam);
int paramid = linitial_int(subplan->setParam);
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
prm->execPlan = NULL;
......@@ -1017,9 +1015,9 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
}
else
{
foreach(lst, subplan->setParam)
foreach(l, subplan->setParam)
{
int paramid = lfirsti(lst);
int paramid = lfirsti(l);
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
prm->execPlan = NULL;
......@@ -1031,7 +1029,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
else if (subLinkType == ARRAY_SUBLINK)
{
/* There can be only one param... */
int paramid = lfirsti(subplan->setParam);
int paramid = linitial_int(subplan->setParam);
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
Assert(astate != NULL);
......@@ -1074,7 +1072,7 @@ ExecReScanSetParamPlan(SubPlanState *node, PlanState *parent)
PlanState *planstate = node->planstate;
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
EState *estate = parent->state;
List *lst;
ListCell *l;
/* sanity checks */
if (subplan->parParam != NIL)
......@@ -1091,9 +1089,9 @@ ExecReScanSetParamPlan(SubPlanState *node, PlanState *parent)
/*
* Mark this subplan's output parameters as needing recalculation
*/
foreach(lst, subplan->setParam)
foreach(l, subplan->setParam)
{
int paramid = lfirsti(lst);
int paramid = lfirsti(l);
ParamExecData *prm = &(estate->es_param_exec_vals[paramid]);
prm->execPlan = node;
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.37 2004/04/21 18:24:26 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.38 2004/05/26 04:41:16 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -45,18 +45,18 @@ TidListCreate(TidScanState *tidstate)
ExprContext *econtext = tidstate->ss.ps.ps_ExprContext;
ItemPointerData *tidList;
int numTids = 0;
List *lst;
ListCell *l;
tidList = (ItemPointerData *)
palloc(length(tidstate->tss_tideval) * sizeof(ItemPointerData));
foreach(lst, evalList)
foreach(l, evalList)
{
ItemPointer itemptr;
bool isNull;
itemptr = (ItemPointer)
DatumGetPointer(ExecEvalExprSwitchContext(lfirst(lst),
DatumGetPointer(ExecEvalExprSwitchContext(lfirst(l),
econtext,
&isNull,
NULL));
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.113 2004/04/01 21:28:44 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.114 2004/05/26 04:41:16 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -744,8 +744,8 @@ SPI_cursor_open(const char *name, void *plan, Datum *Values, const char *Nulls)
ereport(ERROR,
(errcode(ERRCODE_INVALID_CURSOR_DEFINITION),
errmsg("cannot open multi-query plan as cursor")));
queryTree = (Query *) lfirst((List *) lfirst(qtlist));
planTree = (Plan *) lfirst(ptlist);
queryTree = (Query *) linitial((List *) linitial(qtlist));
planTree = (Plan *) linitial(ptlist);
if (queryTree->commandType != CMD_SELECT)
ereport(ERROR,
......@@ -953,7 +953,7 @@ SPI_is_cursor_plan(void *plan)
qtlist = spiplan->qtlist;
if (length(spiplan->ptlist) == 1 && length(qtlist) == 1)
{
Query *queryTree = (Query *) lfirst((List *) lfirst(qtlist));
Query *queryTree = (Query *) linitial((List *) linitial(qtlist));
if (queryTree->commandType == CMD_SELECT && queryTree->into == NULL)
return true;
......@@ -1062,7 +1062,7 @@ _SPI_execute(const char *src, int tcount, _SPI_plan *plan)
List *raw_parsetree_list;
List *query_list_list;
List *plan_list;
List *list_item;
ListCell *list_item;
ErrorContextCallback spierrcontext;
int nargs = 0;
Oid *argtypes = NULL;
......@@ -1110,7 +1110,7 @@ _SPI_execute(const char *src, int tcount, _SPI_plan *plan)
{
Node *parsetree = (Node *) lfirst(list_item);
List *query_list;
List *query_list_item;
ListCell *query_list_item;
query_list = pg_analyze_and_rewrite(parsetree, argtypes, nargs);
......@@ -1207,8 +1207,8 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
bool useCurrentSnapshot, int tcount)
{
List *query_list_list = plan->qtlist;
List *plan_list = plan->ptlist;
List *query_list_list_item;
ListCell *plan_list_item = list_head(plan->ptlist);
ListCell *query_list_list_item;
ErrorContextCallback spierrcontext;
int nargs = plan->nargs;
int res = 0;
......@@ -1254,7 +1254,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
foreach(query_list_list_item, query_list_list)
{
List *query_list = lfirst(query_list_list_item);
List *query_list_item;
ListCell *query_list_item;
/* Reset state for each original parsetree */
/* (at most one of its querytrees will be marked canSetTag) */
......@@ -1270,8 +1270,8 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
QueryDesc *qdesc;
DestReceiver *dest;
planTree = lfirst(plan_list);
plan_list = lnext(plan_list);
planTree = lfirst(plan_list_item);
plan_list_item = lnext(plan_list_item);
dest = CreateDestReceiver(queryTree->canSetTag ? SPI : None, NULL);
if (queryTree->commandType == CMD_UTILITY)
......
......@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.58 2003/11/29 19:51:49 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.59 2004/05/26 04:41:18 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -36,14 +36,14 @@ md5_crypt_verify(const Port *port, const char *user, char *client_pass)
*crypt_pwd;
int retval = STATUS_ERROR;
List **line;
List *token;
ListCell *token;
char *crypt_client_pass = client_pass;
if ((line = get_user_line(user)) == NULL)
return STATUS_ERROR;
/* Skip over line number and username */
token = lnext(lnext(*line));
/* Skip over username */
token = lnext(list_head(*line));
if (token)
{
shadow_pass = lfirst(token);
......
This diff is collapsed.
......@@ -15,11 +15,13 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.281 2004/05/10 22:44:44 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.282 2004/05/26 04:41:18 neilc Exp $
*
*-------------------------------------------------------------------------
*/
#define DISABLE_LIST_COMPAT
#include "postgres.h"
#include "nodes/parsenodes.h"
......@@ -43,14 +45,6 @@
#define COPY_NODE_FIELD(fldname) \
(newnode->fldname = copyObject(from->fldname))
/* Copy a field that is a pointer to a list of integers */
#define COPY_INTLIST_FIELD(fldname) \
(newnode->fldname = listCopy(from->fldname))
/* Copy a field that is a pointer to a list of Oids */
#define COPY_OIDLIST_FIELD(fldname) \
(newnode->fldname = listCopy(from->fldname))
/* Copy a field that is a pointer to a Bitmapset */
#define COPY_BITMAPSET_FIELD(fldname) \
(newnode->fldname = bms_copy(from->fldname))
......@@ -68,46 +62,6 @@
} while (0)
/*
* listCopy
* This copy function only copies the "cons-cells" of the list, not the
* pointed-to objects. (Use copyObject if you want a "deep" copy.)
*
* We also use this function for copying lists of integers and Oids,
* which is notationally a bit ugly, but perfectly safe.
*
* Note that copyObject will surely coredump if applied to a list
* of integers or Oids!
*/
List *
listCopy(List *list)
{
List *newlist,
*oldl,
*newcell,
*prev;
/* rather ugly coding for speed... */
if (list == NIL)
return NIL;
newcell = makeNode(List);
newcell->elem = list->elem;
newlist = prev = newcell;
foreach(oldl, lnext(list))
{
newcell = makeNode(List);
newcell->elem = oldl->elem;
prev->next = newcell;
prev = newcell;
}
prev->next = NIL;
return newlist;
}
/* ****************************************************************
* plannodes.h copy functions
* ****************************************************************
......@@ -259,42 +213,12 @@ _copyIndexScan(IndexScan *from)
/*
* copy remainder of node
*/
COPY_OIDLIST_FIELD(indxid);
COPY_NODE_FIELD(indxid);
COPY_NODE_FIELD(indxqual);
COPY_NODE_FIELD(indxqualorig);
/* this can become COPY_NODE_FIELD when intlists are normal objects: */
{
List *newstrat = NIL;
List *tmp;
foreach(tmp, from->indxstrategy)
{
newstrat = lappend(newstrat, listCopy(lfirst(tmp)));
}
newnode->indxstrategy = newstrat;
}
/* this can become COPY_NODE_FIELD when OID lists are normal objects: */
{
List *newsubtype = NIL;
List *tmp;
foreach(tmp, from->indxsubtype)
{
newsubtype = lappend(newsubtype, listCopy(lfirst(tmp)));
}
newnode->indxsubtype = newsubtype;
}
/* this can become COPY_NODE_FIELD when intlists are normal objects: */
{
List *newstrat = NIL;
List *tmp;
foreach(tmp, from->indxlossy)
{
newstrat = lappend(newstrat, listCopy(lfirst(tmp)));
}
newnode->indxlossy = newstrat;
}
COPY_NODE_FIELD(indxstrategy);
COPY_NODE_FIELD(indxsubtype);
COPY_NODE_FIELD(indxlossy);
COPY_SCALAR_FIELD(indxorderdir);
return newnode;
......@@ -876,7 +800,7 @@ _copySubLink(SubLink *from)
COPY_SCALAR_FIELD(useOr);
COPY_NODE_FIELD(lefthand);
COPY_NODE_FIELD(operName);
COPY_OIDLIST_FIELD(operOids);
COPY_NODE_FIELD(operOids);
COPY_NODE_FIELD(subselect);
return newnode;
......@@ -893,14 +817,14 @@ _copySubPlan(SubPlan *from)
COPY_SCALAR_FIELD(subLinkType);
COPY_SCALAR_FIELD(useOr);
COPY_NODE_FIELD(exprs);
COPY_INTLIST_FIELD(paramIds);
COPY_NODE_FIELD(paramIds);
COPY_NODE_FIELD(plan);
COPY_SCALAR_FIELD(plan_id);
COPY_NODE_FIELD(rtable);
COPY_SCALAR_FIELD(useHashTable);
COPY_SCALAR_FIELD(unknownEqFalse);
COPY_INTLIST_FIELD(setParam);
COPY_INTLIST_FIELD(parParam);
COPY_NODE_FIELD(setParam);
COPY_NODE_FIELD(parParam);
COPY_NODE_FIELD(args);
return newnode;
......@@ -1582,7 +1506,7 @@ _copyQuery(Query *from)
COPY_SCALAR_FIELD(hasSubLinks);
COPY_NODE_FIELD(rtable);
COPY_NODE_FIELD(jointree);
COPY_INTLIST_FIELD(rowMarks);
COPY_NODE_FIELD(rowMarks);
COPY_NODE_FIELD(targetList);
COPY_NODE_FIELD(groupClause);
COPY_NODE_FIELD(havingQual);
......@@ -1591,7 +1515,7 @@ _copyQuery(Query *from)
COPY_NODE_FIELD(limitOffset);
COPY_NODE_FIELD(limitCount);
COPY_NODE_FIELD(setOperations);
COPY_INTLIST_FIELD(resultRelations);
COPY_NODE_FIELD(resultRelations);
COPY_NODE_FIELD(in_info_list);
COPY_SCALAR_FIELD(hasJoinRTEs);
......@@ -1679,7 +1603,7 @@ _copySetOperationStmt(SetOperationStmt *from)
COPY_SCALAR_FIELD(all);
COPY_NODE_FIELD(larg);
COPY_NODE_FIELD(rarg);
COPY_OIDLIST_FIELD(colTypes);
COPY_NODE_FIELD(colTypes);
return newnode;
}
......@@ -1731,7 +1655,7 @@ _copyGrantStmt(GrantStmt *from)
COPY_SCALAR_FIELD(is_grant);
COPY_SCALAR_FIELD(objtype);
COPY_NODE_FIELD(objects);
COPY_INTLIST_FIELD(privileges);
COPY_NODE_FIELD(privileges);
COPY_NODE_FIELD(grantees);
COPY_SCALAR_FIELD(grant_option);
COPY_SCALAR_FIELD(behavior);
......@@ -2477,7 +2401,7 @@ _copyPrepareStmt(PrepareStmt *from)
COPY_STRING_FIELD(name);
COPY_NODE_FIELD(argtypes);
COPY_OIDLIST_FIELD(argtype_oids);
COPY_NODE_FIELD(argtype_oids);
COPY_NODE_FIELD(query);
return newnode;
......@@ -2511,6 +2435,47 @@ _copyDeallocateStmt(DeallocateStmt *from)
* ****************************************************************
*/
/*
* Perform a deep copy of the specified list, using copyObject(). The
* list MUST be of type T_List; T_IntList and T_OidList nodes don't
* need deep copies, so they should be copied via list_copy()
*/
#define COPY_NODE_CELL(new, old) \
(new) = (ListCell *) palloc(sizeof(ListCell)); \
lfirst(new) = copyObject(lfirst(old));
static List *
_copyList(List *from)
{
List *new;
ListCell *curr_old;
ListCell *prev_new;
Assert(list_length(from) >= 1);
new = makeNode(List);
new->length = from->length;
COPY_NODE_CELL(new->head, from->head);
prev_new = new->head;
curr_old = lnext(from->head);
while (curr_old)
{
COPY_NODE_CELL(prev_new->next, curr_old);
prev_new = prev_new->next;
curr_old = curr_old->next;
}
prev_new->next = NULL;
new->tail = prev_new;
return new;
}
/* ****************************************************************
* value.h copy functions
* ****************************************************************
*/
static Value *
_copyValue(Value *from)
{
......@@ -2752,30 +2717,21 @@ copyObject(void *from)
case T_Null:
retval = _copyValue(from);
break;
case T_List:
{
List *list = from,
*oldl,
*newcell,
*prev;
/* rather ugly coding for speed... */
/* Note the input list cannot be NIL if we got here. */
newcell = makeNode(List);
lfirst(newcell) = copyObject(lfirst(list));
retval = (void *) newcell;
prev = newcell;
foreach(oldl, lnext(list))
{
newcell = makeNode(List);
lfirst(newcell) = copyObject(lfirst(oldl));
prev->next = newcell;
prev = newcell;
}
prev->next = NIL;
}
/*
* LIST NODES
*/
case T_List:
retval = _copyList(from);
break;
/*
* Lists of integers and OIDs don't need to be
* deep-copied, so we perform a shallow copy via
* list_copy()
*/
case T_IntList:
case T_OidList:
retval = list_copy(from);
break;
/*
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.66 2004/05/08 21:21:18 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.67 2004/05/26 04:41:19 neilc Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
......@@ -255,7 +255,7 @@ pretty_format_node_dump(const char *dump)
void
print_rt(List *rtable)
{
List *l;
ListCell *l;
int i = 1;
printf("resno\trefname \trelid\tinFromCl\n");
......@@ -395,7 +395,7 @@ print_expr(Node *expr, List *rtable)
{
FuncExpr *e = (FuncExpr *) expr;
char *funcname;
List *l;
ListCell *l;
funcname = get_func_name(e->funcid);
printf("%s(", ((funcname != NULL) ? funcname : "(invalid function)"));
......@@ -418,18 +418,18 @@ print_expr(Node *expr, List *rtable)
void
print_pathkeys(List *pathkeys, List *rtable)
{
List *i,
*k;
ListCell *i;
printf("(");
foreach(i, pathkeys)
{
List *pathkey = lfirst(i);
List *pathkey = (List *) lfirst(i);
ListCell *k;
printf("(");
foreach(k, pathkey)
{
PathKeyItem *item = lfirst(k);
PathKeyItem *item = (PathKeyItem *) lfirst(k);
print_expr(item->key, rtable);
if (lnext(k))
......@@ -449,12 +449,12 @@ print_pathkeys(List *pathkeys, List *rtable)
void
print_tl(List *tlist, List *rtable)
{
List *tl;
ListCell *tl;
printf("(\n");
foreach(tl, tlist)
{
TargetEntry *tle = lfirst(tl);
TargetEntry *tle = (TargetEntry *) lfirst(tl);
printf("\t%d %s\t", tle->resdom->resno,
tle->resdom->resname ? tle->resdom->resname : "<null>");
......@@ -590,13 +590,13 @@ print_plan_recursive(Plan *p, Query *parsetree, int indentLevel, char *label)
if (IsA(p, Append))
{
List *lst;
ListCell *l;
int whichplan = 0;
Append *appendplan = (Append *) p;
foreach(lst, appendplan->appendplans)
foreach(l, appendplan->appendplans)
{
Plan *subnode = (Plan *) lfirst(lst);
Plan *subnode = (Plan *) lfirst(l);
/*
* I don't think we need to fiddle with the range table here,
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/read.c,v 1.41 2004/05/08 21:21:18 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/read.c,v 1.42 2004/05/26 04:41:19 neilc Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
......@@ -384,7 +384,6 @@ nodeRead(char *token, int tok_len)
}
break;
case T_Integer:
/*
* we know that the token terminates on a char atol will stop
* at
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.169 2004/05/10 22:44:44 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.170 2004/05/26 04:41:19 neilc Exp $
*
* NOTES
* Path and Plan nodes do not have any readfuncs support, because we
......@@ -18,6 +18,8 @@
*
*-------------------------------------------------------------------------
*/
#define DISABLE_LIST_COMPAT
#include "postgres.h"
#include <math.h>
......@@ -33,11 +35,7 @@
* routine.
*/
/* Declare appropriate local variables */
#define READ_LOCALS(nodeTypeName) \
nodeTypeName *local_node = makeNode(nodeTypeName); \
char *token; \
int length
/* Macros for declaring appropriate local variables */
/* A few guys need only local_node */
#define READ_LOCALS_NO_FIELDS(nodeTypeName) \
......@@ -48,6 +46,11 @@
char *token; \
int length
/* ... but most need both */
#define READ_LOCALS(nodeTypeName) \
READ_LOCALS_NO_FIELDS(nodeTypeName); \
READ_TEMP_LOCALS()
/* Read an integer field (anything written as ":fldname %d") */
#define READ_INT_FIELD(fldname) \
token = pg_strtok(&length); /* skip :fldname */ \
......@@ -101,16 +104,6 @@
token = pg_strtok(&length); /* skip :fldname */ \
local_node->fldname = nodeRead(NULL, 0)
/* Read an integer-list field (XXX combine me with READ_NODE_FIELD) */
#define READ_INTLIST_FIELD(fldname) \
token = pg_strtok(&length); /* skip :fldname */ \
local_node->fldname = nodeRead(NULL, 0)
/* Read an OID-list field (XXX combine me with READ_NODE_FIELD) */
#define READ_OIDLIST_FIELD(fldname) \
token = pg_strtok(&length); /* skip :fldname */ \
local_node->fldname = nodeRead(NULL, 0)
/* Routine exit */
#define READ_DONE() \
return local_node
......@@ -153,7 +146,7 @@ _readQuery(void)
READ_BOOL_FIELD(hasSubLinks);
READ_NODE_FIELD(rtable);
READ_NODE_FIELD(jointree);
READ_INTLIST_FIELD(rowMarks);
READ_NODE_FIELD(rowMarks);
READ_NODE_FIELD(targetList);
READ_NODE_FIELD(groupClause);
READ_NODE_FIELD(havingQual);
......@@ -162,7 +155,7 @@ _readQuery(void)
READ_NODE_FIELD(limitOffset);
READ_NODE_FIELD(limitCount);
READ_NODE_FIELD(setOperations);
READ_INTLIST_FIELD(resultRelations);
READ_NODE_FIELD(resultRelations);
/* planner-internal fields are left zero */
......@@ -237,7 +230,7 @@ _readSetOperationStmt(void)
READ_BOOL_FIELD(all);
READ_NODE_FIELD(larg);
READ_NODE_FIELD(rarg);
READ_OIDLIST_FIELD(colTypes);
READ_NODE_FIELD(colTypes);
READ_DONE();
}
......@@ -526,7 +519,7 @@ _readSubLink(void)
READ_BOOL_FIELD(useOr);
READ_NODE_FIELD(lefthand);
READ_NODE_FIELD(operName);
READ_OIDLIST_FIELD(operOids);
READ_NODE_FIELD(operOids);
READ_NODE_FIELD(subselect);
READ_DONE();
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment