diff options
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/adt/name.c | 13 | ||||
-rw-r--r-- | src/backend/utils/adt/regproc.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/ri_triggers.c | 24 | ||||
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 150 | ||||
-rw-r--r-- | src/backend/utils/adt/selfuncs.c | 30 | ||||
-rw-r--r-- | src/backend/utils/adt/tid.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/varlena.c | 4 | ||||
-rw-r--r-- | src/backend/utils/cache/catcache.c | 8 | ||||
-rw-r--r-- | src/backend/utils/cache/relcache.c | 25 | ||||
-rw-r--r-- | src/backend/utils/cache/typcache.c | 4 | ||||
-rw-r--r-- | src/backend/utils/init/miscinit.c | 4 | ||||
-rw-r--r-- | src/backend/utils/misc/guc.c | 10 |
12 files changed, 146 insertions, 134 deletions
diff --git a/src/backend/utils/adt/name.c b/src/backend/utils/adt/name.c index 0bd8658b9f3..bb34667c4d3 100644 --- a/src/backend/utils/adt/name.c +++ b/src/backend/utils/adt/name.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/name.c,v 1.50 2003/11/29 19:51:59 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/name.c,v 1.51 2004/05/26 04:41:37 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -342,7 +342,8 @@ current_schema(PG_FUNCTION_ARGS) if (search_path == NIL) PG_RETURN_NULL(); - nspname = get_namespace_name(lfirsto(search_path)); + nspname = get_namespace_name(linitial_oid(search_path)); + list_free(search_path); if (!nspname) PG_RETURN_NULL(); /* recently-deleted namespace? */ PG_RETURN_DATUM(DirectFunctionCall1(namein, CStringGetDatum(nspname))); @@ -352,25 +353,27 @@ Datum current_schemas(PG_FUNCTION_ARGS) { List *search_path = fetch_search_path(PG_GETARG_BOOL(0)); + ListCell *l; Datum *names; int i; ArrayType *array; /* +1 here is just to avoid palloc(0) error */ + names = (Datum *) palloc((length(search_path) + 1) * sizeof(Datum)); i = 0; - while (search_path) + foreach(l, search_path) { char *nspname; - nspname = get_namespace_name(lfirsto(search_path)); + nspname = get_namespace_name(lfirst_oid(l)); if (nspname) /* watch out for deleted namespace */ { names[i] = DirectFunctionCall1(namein, CStringGetDatum(nspname)); i++; } - search_path = lnext(search_path); } + list_free(search_path); array = construct_array(names, i, NAMEOID, diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index fe2e7aa6cf8..9c688401ece 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.87 2004/05/07 00:24:58 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.88 2004/05/26 04:41:37 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -1099,7 +1099,7 @@ stringToQualifiedNameList(const char *string, const char *caller) char *rawname; List *result = NIL; List *namelist; - List *l; + ListCell *l; /* We need a modifiable copy of the input string. */ rawname = pstrdup(string); diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 47384fbb89f..9e3a06cd822 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -17,7 +17,7 @@ * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.67 2004/02/03 17:34:03 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.68 2004/05/26 04:41:38 neilc Exp $ * * ---------- */ @@ -2571,8 +2571,8 @@ RI_Initial_Check(FkConstraint *fkconstraint, Relation rel, Relation pkrel) char attname[MAX_QUOTED_NAME_LEN]; char fkattname[MAX_QUOTED_NAME_LEN]; const char *sep; - List *list; - List *list2; + ListCell *l; + ListCell *l2; int old_work_mem; char workmembuf[32]; int spi_result; @@ -2605,9 +2605,9 @@ RI_Initial_Check(FkConstraint *fkconstraint, Relation rel, Relation pkrel) sprintf(querystr, "SELECT "); sep=""; - foreach(list, fkconstraint->fk_attrs) + foreach(l, fkconstraint->fk_attrs) { - quoteOneName(attname, strVal(lfirst(list))); + quoteOneName(attname, strVal(lfirst(l))); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%sfk.%s", sep, attname); sep = ", "; @@ -2620,12 +2620,10 @@ RI_Initial_Check(FkConstraint *fkconstraint, Relation rel, Relation pkrel) relname, pkrelname); sep=""; - for (list=fkconstraint->pk_attrs, list2=fkconstraint->fk_attrs; - list != NIL && list2 != NIL; - list=lnext(list), list2=lnext(list2)) + forboth(l, fkconstraint->pk_attrs, l2, fkconstraint->fk_attrs) { - quoteOneName(attname, strVal(lfirst(list))); - quoteOneName(fkattname, strVal(lfirst(list2))); + quoteOneName(attname, strVal(lfirst(l))); + quoteOneName(fkattname, strVal(lfirst(l2))); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%spk.%s=fk.%s", sep, attname, fkattname); @@ -2635,14 +2633,14 @@ RI_Initial_Check(FkConstraint *fkconstraint, Relation rel, Relation pkrel) * It's sufficient to test any one pk attribute for null to detect a * join failure. */ - quoteOneName(attname, strVal(lfirst(fkconstraint->pk_attrs))); + quoteOneName(attname, strVal(linitial(fkconstraint->pk_attrs))); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), ") WHERE pk.%s IS NULL AND (", attname); sep=""; - foreach(list, fkconstraint->fk_attrs) + foreach(l, fkconstraint->fk_attrs) { - quoteOneName(attname, strVal(lfirst(list))); + quoteOneName(attname, strVal(lfirst(l))); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%sfk.%s IS NOT NULL", sep, attname); diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 95e457c261f..213dc61202b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3,7 +3,7 @@ * back to source text * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.166 2004/05/10 22:44:46 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.167 2004/05/26 04:41:38 neilc Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -627,6 +627,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, int prettyFlags) Form_pg_class idxrelrec; Form_pg_am amrec; List *indexprs; + ListCell *indexpr_item; List *context; Oid indrelid; int keyno; @@ -691,6 +692,8 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, int prettyFlags) else indexprs = NIL; + indexpr_item = list_head(indexprs); + context = deparse_context_for(get_rel_name(indrelid), indrelid); /* @@ -733,10 +736,10 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, int prettyFlags) /* expressional index */ Node *indexkey; - if (indexprs == NIL) + if (indexpr_item == NULL) elog(ERROR, "too few entries in indexprs list"); - indexkey = (Node *) lfirst(indexprs); - indexprs = lnext(indexprs); + indexkey = (Node *) lfirst(indexpr_item); + indexpr_item = lnext(indexpr_item); /* Deparse */ str = deparse_expression_pretty(indexkey, context, false, false, prettyFlags, 0); @@ -1358,7 +1361,7 @@ deparse_context_for_subplan(const char *name, List *tlist, List *attrs = NIL; int nattrs = 0; int rtablelength = length(rtable); - List *tl; + ListCell *tl; char buf[32]; foreach(tl, tlist) @@ -1526,7 +1529,7 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, * (which can only be references to OLD and NEW). Use the rtable * of the first query in the action list for this purpose. */ - query = (Query *) lfirst(actions); + query = (Query *) linitial(actions); /* * If the action is INSERT...SELECT, OLD/NEW have been pushed down @@ -1556,7 +1559,7 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, /* Finally the rules actions */ if (length(actions) > 1) { - List *action; + ListCell *action; Query *query; appendStringInfo(buf, "("); @@ -1579,7 +1582,7 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, { Query *query; - query = (Query *) lfirst(actions); + query = (Query *) linitial(actions); get_query_def(query, buf, NIL, NULL, prettyFlags, 0); appendStringInfo(buf, ";"); } @@ -1636,7 +1639,7 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, return; } - query = (Query *) lfirst(actions); + query = (Query *) linitial(actions); if (ev_type != '1' || ev_attr >= 0 || !is_instead || strcmp(ev_qual, "<>") != 0 || query->commandType != CMD_SELECT) @@ -1670,7 +1673,7 @@ get_query_def(Query *query, StringInfo buf, List *parentnamespace, deparse_namespace dpns; context.buf = buf; - context.namespaces = lcons(&dpns, parentnamespace); + context.namespaces = lcons(&dpns, list_copy(parentnamespace)); context.varprefix = (parentnamespace != NIL || length(query->rtable) != 1); context.prettyFlags = prettyFlags; @@ -1725,7 +1728,7 @@ get_select_query_def(Query *query, deparse_context *context, StringInfo buf = context->buf; bool force_colno; char *sep; - List *l; + ListCell *l; /* * If the Query node has a setOperations tree, then it's the top level @@ -1802,7 +1805,7 @@ get_basic_select_query(Query *query, deparse_context *context, { StringInfo buf = context->buf; char *sep; - List *l; + ListCell *l; int colno; /* @@ -2057,7 +2060,7 @@ get_insert_query_def(Query *query, deparse_context *context) RangeTblEntry *select_rte = NULL; RangeTblEntry *rte; char *sep; - List *l; + ListCell *l; /* * If it's an INSERT ... SELECT there will be a single subquery RTE @@ -2136,10 +2139,10 @@ get_insert_query_def(Query *query, deparse_context *context) static void get_update_query_def(Query *query, deparse_context *context) { - StringInfo buf = context->buf; - char *sep; - RangeTblEntry *rte; - List *l; + StringInfo buf = context->buf; + char *sep; + RangeTblEntry *rte; + ListCell *l; /* * Start the query with UPDATE relname SET @@ -2271,17 +2274,17 @@ static void get_names_for_var(Var *var, deparse_context *context, char **schemaname, char **refname, char **attname) { - List *nslist = context->namespaces; + ListCell *nslist_item = list_head(context->namespaces); int sup = var->varlevelsup; deparse_namespace *dpns; RangeTblEntry *rte; /* Find appropriate nesting depth */ - while (sup-- > 0 && nslist != NIL) - nslist = lnext(nslist); - if (nslist == NIL) + while (sup-- > 0 && nslist_item != NULL) + nslist_item = lnext(nslist_item); + if (nslist_item == NULL) elog(ERROR, "bogus varlevelsup: %d", var->varlevelsup); - dpns = (deparse_namespace *) lfirst(nslist); + dpns = (deparse_namespace *) lfirst(nslist_item); /* Find the relevant RTE */ if (var->varno >= 1 && var->varno <= length(dpns->rtable)) @@ -2342,13 +2345,13 @@ get_names_for_var(Var *var, deparse_context *context, static RangeTblEntry * find_rte_by_refname(const char *refname, deparse_context *context) { - RangeTblEntry *result = NULL; - List *nslist; + RangeTblEntry *result = NULL; + ListCell *nslist; foreach(nslist, context->namespaces) { deparse_namespace *dpns = (deparse_namespace *) lfirst(nslist); - List *rtlist; + ListCell *rtlist; foreach(rtlist, dpns->rtable) { @@ -2396,7 +2399,7 @@ get_simple_binary_op_name(OpExpr *expr) if (length(args) == 2) { /* binary operator */ - Node *arg1 = (Node *) lfirst(args); + Node *arg1 = (Node *) linitial(args); Node *arg2 = (Node *) lsecond(args); const char *op; @@ -2501,7 +2504,7 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags) * Operators are same priority --- can skip parens * only if we have (a - b) - c, not a - (b - c). */ - if (node == (Node *) lfirst(((OpExpr *) parentNode)->args)) + if (node == (Node *) linitial(((OpExpr *) parentNode)->args)) return true; return false; @@ -2759,8 +2762,8 @@ get_rule_expr(Node *node, deparse_context *context, ArrayRef *aref = (ArrayRef *) node; bool savevarprefix = context->varprefix; bool need_parens; - List *lowlist; - List *uplist; + ListCell *lowlist_item; + ListCell *uplist_item; /* * If we are doing UPDATE array[n] = expr, we need to @@ -2783,18 +2786,19 @@ get_rule_expr(Node *node, deparse_context *context, if (need_parens) appendStringInfoChar(buf, ')'); context->varprefix = savevarprefix; - lowlist = aref->reflowerindexpr; - foreach(uplist, aref->refupperindexpr) + lowlist_item = list_head(aref->reflowerindexpr); + foreach(uplist_item, aref->refupperindexpr) { appendStringInfo(buf, "["); - if (lowlist) + if (lowlist_item) { - get_rule_expr((Node *) lfirst(lowlist), context, + get_rule_expr((Node *) lfirst(lowlist_item), context, false); appendStringInfo(buf, ":"); - lowlist = lnext(lowlist); + lowlist_item = lnext(lowlist_item); } - get_rule_expr((Node *) lfirst(uplist), context, false); + get_rule_expr((Node *) lfirst(uplist_item), + context, false); appendStringInfo(buf, "]"); } if (aref->refassgnexpr) @@ -2818,7 +2822,7 @@ get_rule_expr(Node *node, deparse_context *context, { DistinctExpr *expr = (DistinctExpr *) node; List *args = expr->args; - Node *arg1 = (Node *) lfirst(args); + Node *arg1 = (Node *) linitial(args); Node *arg2 = (Node *) lsecond(args); if (!PRETTY_PAREN(context)) @@ -2835,7 +2839,7 @@ get_rule_expr(Node *node, deparse_context *context, { ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node; List *args = expr->args; - Node *arg1 = (Node *) lfirst(args); + Node *arg1 = (Node *) linitial(args); Node *arg2 = (Node *) lsecond(args); if (!PRETTY_PAREN(context)) @@ -2856,20 +2860,22 @@ get_rule_expr(Node *node, deparse_context *context, case T_BoolExpr: { BoolExpr *expr = (BoolExpr *) node; - List *args = expr->args; + Node *first_arg = linitial(expr->args); + ListCell *arg = lnext(list_head(expr->args)); switch (expr->boolop) { case AND_EXPR: if (!PRETTY_PAREN(context)) appendStringInfoChar(buf, '('); - get_rule_expr_paren((Node *) lfirst(args), context, + get_rule_expr_paren(first_arg, context, false, node); - while ((args = lnext(args)) != NIL) + while (arg) { appendStringInfo(buf, " AND "); - get_rule_expr_paren((Node *) lfirst(args), context, + get_rule_expr_paren((Node *) lfirst(arg), context, false, node); + arg = lnext(arg); } if (!PRETTY_PAREN(context)) appendStringInfoChar(buf, ')'); @@ -2878,13 +2884,14 @@ get_rule_expr(Node *node, deparse_context *context, case OR_EXPR: if (!PRETTY_PAREN(context)) appendStringInfoChar(buf, '('); - get_rule_expr_paren((Node *) lfirst(args), context, + get_rule_expr_paren(first_arg, context, false, node); - while ((args = lnext(args)) != NIL) + while (arg) { appendStringInfo(buf, " OR "); - get_rule_expr_paren((Node *) lfirst(args), context, + get_rule_expr_paren((Node *) lfirst(arg), context, false, node); + arg = lnext(arg); } if (!PRETTY_PAREN(context)) appendStringInfoChar(buf, ')'); @@ -2894,7 +2901,7 @@ get_rule_expr(Node *node, deparse_context *context, if (!PRETTY_PAREN(context)) appendStringInfoChar(buf, '('); appendStringInfo(buf, "NOT "); - get_rule_expr_paren((Node *) lfirst(args), context, + get_rule_expr_paren(first_arg, context, false, node); if (!PRETTY_PAREN(context)) appendStringInfoChar(buf, ')'); @@ -2989,7 +2996,7 @@ get_rule_expr(Node *node, deparse_context *context, case T_CaseExpr: { CaseExpr *caseexpr = (CaseExpr *) node; - List *temp; + ListCell *temp; appendContextKeyword(context, "CASE", 0, PRETTYINDENT_VAR, 0); @@ -3035,7 +3042,7 @@ get_rule_expr(Node *node, deparse_context *context, case T_ArrayExpr: { ArrayExpr *arrayexpr = (ArrayExpr *) node; - List *element; + ListCell *element; char *sep; appendStringInfo(buf, "ARRAY["); @@ -3055,7 +3062,7 @@ get_rule_expr(Node *node, deparse_context *context, case T_RowExpr: { RowExpr *rowexpr = (RowExpr *) node; - List *arg; + ListCell *arg; char *sep; /* @@ -3082,7 +3089,7 @@ get_rule_expr(Node *node, deparse_context *context, case T_CoalesceExpr: { CoalesceExpr *coalesceexpr = (CoalesceExpr *) node; - List *arg; + ListCell *arg; char *sep; appendStringInfo(buf, "COALESCE("); @@ -3102,7 +3109,7 @@ get_rule_expr(Node *node, deparse_context *context, case T_NullIfExpr: { NullIfExpr *nullifexpr = (NullIfExpr *) node; - List *arg; + ListCell *arg; char *sep; appendStringInfo(buf, "NULLIF("); @@ -3239,7 +3246,7 @@ get_oper_expr(OpExpr *expr, deparse_context *context) if (length(args) == 2) { /* binary operator */ - Node *arg1 = (Node *) lfirst(args); + Node *arg1 = (Node *) linitial(args); Node *arg2 = (Node *) lsecond(args); get_rule_expr_paren(arg1, context, true, (Node *) expr); @@ -3252,7 +3259,7 @@ get_oper_expr(OpExpr *expr, deparse_context *context) else { /* unary operator --- but which side? */ - Node *arg = (Node *) lfirst(args); + Node *arg = (Node *) linitial(args); HeapTuple tp; Form_pg_operator optup; @@ -3298,7 +3305,7 @@ get_func_expr(FuncExpr *expr, deparse_context *context, Oid funcoid = expr->funcid; Oid argtypes[FUNC_MAX_ARGS]; int nargs; - List *l; + ListCell *l; char *sep; /* @@ -3308,7 +3315,7 @@ get_func_expr(FuncExpr *expr, deparse_context *context, */ if (expr->funcformat == COERCE_IMPLICIT_CAST && !showimplicit) { - get_rule_expr_paren((Node *) lfirst(expr->args), context, + get_rule_expr_paren((Node *) linitial(expr->args), context, showimplicit, (Node *) expr); return; } @@ -3320,7 +3327,7 @@ get_func_expr(FuncExpr *expr, deparse_context *context, if (expr->funcformat == COERCE_EXPLICIT_CAST || expr->funcformat == COERCE_IMPLICIT_CAST) { - Node *arg = lfirst(expr->args); + Node *arg = linitial(expr->args); Oid rettype = expr->funcresulttype; int32 coercedTypmod; @@ -3424,7 +3431,7 @@ strip_type_coercion(Node *expr, Oid resultType) if (exprIsLengthCoercion(expr, NULL)) return expr; - return (Node *) lfirst(func->args); + return (Node *) linitial(func->args); } return expr; @@ -3580,7 +3587,7 @@ get_sublink_expr(SubLink *sublink, deparse_context *context) { StringInfo buf = context->buf; Query *query = (Query *) (sublink->subselect); - List *l; + ListCell *l; char *sep; bool need_paren; @@ -3625,7 +3632,7 @@ get_sublink_expr(SubLink *sublink, deparse_context *context) case ANY_SUBLINK: if (length(sublink->operName) == 1 && - strcmp(strVal(lfirst(sublink->operName)), "=") == 0) + strcmp(strVal(linitial(sublink->operName)), "=") == 0) { /* Represent = ANY as IN */ appendStringInfo(buf, "IN "); @@ -3680,7 +3687,7 @@ get_from_clause(Query *query, deparse_context *context) { StringInfo buf = context->buf; bool first = true; - List *l; + ListCell *l; /* * We use the query's jointree as a guide to what to print. However, @@ -3763,12 +3770,12 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) gavealias = true; if (rte->alias->colnames != NIL && coldeflist == NIL) { - List *col; + ListCell *col; appendStringInfoChar(buf, '('); foreach(col, rte->alias->colnames) { - if (col != rte->alias->colnames) + if (col != list_head(rte->alias->colnames)) appendStringInfo(buf, ", "); appendStringInfoString(buf, quote_identifier(strVal(lfirst(col)))); @@ -3897,12 +3904,12 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) { if (j->using) { - List *col; + ListCell *col; appendStringInfo(buf, " USING ("); foreach(col, j->using) { - if (col != j->using) + if (col != list_head(j->using)) appendStringInfo(buf, ", "); appendStringInfoString(buf, quote_identifier(strVal(lfirst(col)))); @@ -3929,12 +3936,12 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) quote_identifier(j->alias->aliasname)); if (j->alias->colnames != NIL) { - List *col; + ListCell *col; appendStringInfoChar(buf, '('); foreach(col, j->alias->colnames) { - if (col != j->alias->colnames) + if (col != list_head(j->alias->colnames)) appendStringInfo(buf, ", "); appendStringInfoString(buf, quote_identifier(strVal(lfirst(col)))); @@ -3958,7 +3965,7 @@ static void get_from_clause_coldeflist(List *coldeflist, deparse_context *context) { StringInfo buf = context->buf; - List *col; + ListCell *col; int i = 0; appendStringInfoChar(buf, '('); @@ -4337,20 +4344,21 @@ generate_operator_name(Oid operid, Oid arg1, Oid arg2) static void print_operator_name(StringInfo buf, List *opname) { - int nnames = length(opname); + ListCell *op = list_head(opname); + int nnames = length(opname); if (nnames == 1) - appendStringInfoString(buf, strVal(lfirst(opname))); + appendStringInfoString(buf, strVal(lfirst(op))); else { appendStringInfo(buf, "OPERATOR("); while (nnames-- > 1) { appendStringInfo(buf, "%s.", - quote_identifier(strVal(lfirst(opname)))); - opname = lnext(opname); + quote_identifier(strVal(lfirst(op)))); + op = lnext(op); } - appendStringInfo(buf, "%s)", strVal(lfirst(opname))); + appendStringInfo(buf, "%s)", strVal(lfirst(op))); } } diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index ded7260c784..cd9a6444d41 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.158 2004/02/27 21:44:34 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.159 2004/05/26 04:41:39 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -1936,7 +1936,7 @@ estimate_num_groups(Query *root, List *groupExprs, double input_rows) List *allvars = NIL; List *varinfos = NIL; double numdistinct; - List *l; + ListCell *l; typedef struct { /* varinfos is a List of these */ Var *var; @@ -1987,14 +1987,14 @@ estimate_num_groups(Query *root, List *groupExprs, double input_rows) VariableStatData vardata; double ndistinct; bool keep = true; - List *l2; + ListCell *l2; examine_variable(root, (Node *) var, 0, &vardata); ndistinct = get_variable_numdistinct(&vardata); ReleaseVariableStats(vardata); /* cannot use foreach here because of possible lremove */ - l2 = varinfos; + l2 = list_head(varinfos); while (l2) { MyVarInfo *varinfo = (MyVarInfo *) lfirst(l2); @@ -2043,7 +2043,7 @@ estimate_num_groups(Query *root, List *groupExprs, double input_rows) do { - MyVarInfo *varinfo1 = (MyVarInfo *) lfirst(varinfos); + MyVarInfo *varinfo1 = (MyVarInfo *) linitial(varinfos); RelOptInfo *rel = find_base_rel(root, varinfo1->var->varno); double reldistinct = varinfo1->ndistinct; List *newvarinfos = NIL; @@ -2052,7 +2052,7 @@ estimate_num_groups(Query *root, List *groupExprs, double input_rows) * Get the largest numdistinct estimate of the Vars for this rel. * Also, construct new varinfos list of remaining Vars. */ - foreach(l, lnext(varinfos)) + for_each_cell(l, lnext(list_head(varinfos))) { MyVarInfo *varinfo2 = (MyVarInfo *) lfirst(l); @@ -2844,7 +2844,7 @@ get_restriction_variable(Query *root, List *args, int varRelid, if (length(args) != 2) return false; - left = (Node *) lfirst(args); + left = (Node *) linitial(args); right = (Node *) lsecond(args); /* @@ -2895,7 +2895,7 @@ get_join_variables(Query *root, List *args, if (length(args) != 2) elog(ERROR, "join operator should take two arguments"); - left = (Node *) lfirst(args); + left = (Node *) linitial(args); right = (Node *) lsecond(args); examine_variable(root, left, 0, vardata1); @@ -3033,16 +3033,16 @@ examine_variable(Query *root, Node *node, int varRelid, * different index opclasses; if so, we need to pick one that * matches the operator we are estimating for. FIXME later. */ - List *ilist; + ListCell *ilist; foreach(ilist, onerel->indexlist) { IndexOptInfo *index = (IndexOptInfo *) lfirst(ilist); - List *indexprs; + ListCell *indexpr_item; int pos; - indexprs = index->indexprs; - if (indexprs == NIL) + indexpr_item = list_head(index->indexprs); + if (indexpr_item == NULL) continue; /* no expressions here... */ /* @@ -3058,9 +3058,9 @@ examine_variable(Query *root, Node *node, int varRelid, { Node *indexkey; - if (indexprs == NIL) + if (indexpr_item == NULL) elog(ERROR, "too few entries in indexprs list"); - indexkey = (Node *) lfirst(indexprs); + indexkey = (Node *) lfirst(indexpr_item); if (indexkey && IsA(indexkey, RelabelType)) indexkey = (Node *) ((RelabelType *) indexkey)->arg; if (equal(node, indexkey)) @@ -3081,7 +3081,7 @@ examine_variable(Query *root, Node *node, int varRelid, if (vardata->statsTuple) break; } - indexprs = lnext(indexprs); + indexpr_item = lnext(indexpr_item); } } if (vardata->statsTuple) diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c index 8433bc98c4d..f8f207d72ab 100644 --- a/src/backend/utils/adt/tid.c +++ b/src/backend/utils/adt/tid.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tid.c,v 1.43 2004/05/07 00:24:58 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tid.c,v 1.44 2004/05/26 04:41:39 neilc Exp $ * * NOTES * input routine largely stolen from boxin(). @@ -241,7 +241,7 @@ currtid_for_view(Relation viewrel, ItemPointer tid) if (length(rewrite->actions) != 1) elog(ERROR, "only one select rule is allowed in views"); - query = (Query *) lfirst(rewrite->actions); + query = (Query *) linitial(rewrite->actions); tle = get_tle_by_resno(query->targetList, tididx+1); if (tle && tle->expr && IsA(tle->expr, Var)) { diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index f329486321d..410faad6925 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.112 2004/02/21 00:34:53 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.113 2004/05/26 04:41:39 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -1623,7 +1623,7 @@ textToQualifiedNameList(text *textval, const char *caller) char *rawname; List *result = NIL; List *namelist; - List *l; + ListCell *l; /* Convert to C string (handles possible detoasting). */ /* Note we rely on being able to modify rawname below. */ diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 5732e5ab424..5e91a7283ec 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.111 2003/11/29 19:52:00 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.112 2004/05/26 04:41:40 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -1317,6 +1317,7 @@ SearchCatCacheList(CatCache *cache, CatCList *cl; CatCTup *ct; List *ctlist; + ListCell *ctlist_item; int nmembers; Relation relation; SysScanDesc scandesc; @@ -1510,15 +1511,16 @@ SearchCatCacheList(CatCache *cache, cl->hash_value = lHashValue; cl->n_members = nmembers; /* The list is backwards because we built it with lcons */ + ctlist_item = list_head(ctlist); for (i = nmembers; --i >= 0;) { - cl->members[i] = ct = (CatCTup *) lfirst(ctlist); + cl->members[i] = ct = (CatCTup *) lfirst(ctlist_item); Assert(ct->c_list == NULL); ct->c_list = cl; /* mark list dead if any members already dead */ if (ct->dead) cl->dead = true; - ctlist = lnext(ctlist); + ctlist_item = lnext(ctlist_item); } DLAddHead(&cache->cc_lists, &cl->cache_elem); diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 0e4a31745fd..4d8190a7b0f 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.202 2004/05/08 19:09:25 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.203 2004/05/26 04:41:40 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -1872,7 +1872,7 @@ RelationCacheInvalidate(void) Relation relation; List *rebuildFirstList = NIL; List *rebuildList = NIL; - List *l; + ListCell *l; /* Phase 1 */ hash_seq_init(&status, RelationIdCache); @@ -2577,23 +2577,24 @@ RelationGetIndexList(Relation relation) static List * insert_ordered_oid(List *list, Oid datum) { - List *l; + ListCell *prev; /* Does the datum belong at the front? */ - if (list == NIL || datum < lfirsto(list)) - return lconso(datum, list); + if (list == NIL || datum < linitial_oid(list)) + return lcons_oid(datum, list); /* No, so find the entry it belongs after */ - l = list; + prev = list_head(list); for (;;) { - List *n = lnext(l); + ListCell *curr = lnext(prev); - if (n == NIL || datum < lfirsto(n)) - break; /* it belongs before n */ - l = n; + if (curr == NULL || datum < lfirst_oid(curr)) + break; /* it belongs after 'prev', before 'curr' */ + + prev = curr; } - /* Insert datum into list after item l */ - lnext(l) = lconso(datum, lnext(l)); + /* Insert datum into list after 'prev' */ + lappend_cell_oid(list, prev, datum); return list; } diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c index 7a8e67c83c8..b3ef61c2d72 100644 --- a/src/backend/utils/cache/typcache.c +++ b/src/backend/utils/cache/typcache.c @@ -36,7 +36,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.5 2004/04/01 21:28:45 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.6 2004/05/26 04:41:40 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -432,7 +432,7 @@ assign_record_type_typmod(TupleDesc tupDesc) Oid hashkey[REC_HASH_KEYS]; bool found; int i; - List *l; + ListCell *l; int32 newtypmod; MemoryContext oldcxt; diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 75cc07a518d..6507891d66d 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.124 2004/04/19 17:42:58 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.125 2004/05/26 04:41:43 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -883,7 +883,7 @@ process_preload_libraries(char *preload_libraries_string) { char *rawstring; List *elemlist; - List *l; + ListCell *l; if (preload_libraries_string == NULL) return; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8a51e8aa049..1cfc3e0346b 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut <peter_e@gmx.net>. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.206 2004/05/21 05:08:03 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.207 2004/05/26 04:41:43 neilc Exp $ * *-------------------------------------------------------------------- */ @@ -3290,7 +3290,7 @@ flatten_set_variable_args(const char *name, List *args) struct config_generic *record; int flags; StringInfoData buf; - List *l; + ListCell *l; /* * Fast path if just DEFAULT. We do not check the variable name in @@ -3310,7 +3310,7 @@ flatten_set_variable_args(const char *name, List *args) /* Complain if list input and non-list variable */ if ((flags & GUC_LIST_INPUT) == 0 && - lnext(args) != NIL) + list_length(args) != 1) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("SET %s takes only one argument", name))); @@ -3322,7 +3322,7 @@ flatten_set_variable_args(const char *name, List *args) A_Const *arg = (A_Const *) lfirst(l); char *val; - if (l != args) + if (l != list_head(args)) appendStringInfo(&buf, ", "); if (!IsA(arg, A_Const)) @@ -4430,7 +4430,7 @@ assign_log_destination(const char *value, bool doit, GucSource source) { char *rawstring; List *elemlist; - List *l; + ListCell *l; unsigned int newlogdest = 0; /* Need a modifiable copy of string */ |