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