1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +03:00

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

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

View File

@@ -16,7 +16,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.19 2004/05/26 18:35:41 tgl Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.20 2004/05/30 23:40:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -224,7 +224,7 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join)
* Adjust level-0 varnos in subquery so that we can append its
* rangetable to upper query's.
*/
rtoffset = length(parse->rtable);
rtoffset = list_length(parse->rtable);
OffsetVarNodes((Node *) subquery, rtoffset, 0);
/*
@@ -269,14 +269,14 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join)
* hold off until after fixing the upper rtable entries; no
* point in running that code on the subquery ones too.)
*/
parse->rtable = nconc(parse->rtable, subquery->rtable);
parse->rtable = list_concat(parse->rtable, subquery->rtable);
/*
* Pull up any FOR UPDATE markers, too. (OffsetVarNodes
* already adjusted the marker values, so just nconc the
* list.)
* already adjusted the marker values, so just list_concat
* the list.)
*/
parse->rowMarks = nconc(parse->rowMarks, subquery->rowMarks);
parse->rowMarks = list_concat(parse->rowMarks, subquery->rowMarks);
/*
* We also have to fix the relid sets of any parent
@@ -295,8 +295,8 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join)
/*
* And now append any subquery InClauseInfos to our list.
*/
parse->in_info_list = nconc(parse->in_info_list,
subquery->in_info_list);
parse->in_info_list = list_concat(parse->in_info_list,
subquery->in_info_list);
/*
* Miscellaneous housekeeping.
@@ -662,7 +662,7 @@ reduce_outer_joins_pass2(Node *jtnode,
pass_nonnullable = bms_add_members(pass_nonnullable,
nonnullable_rels);
/* And recurse --- but only into interesting subtrees */
Assert(length(f->fromlist) == length(state->sub_states));
Assert(list_length(f->fromlist) == list_length(state->sub_states));
forboth(l, f->fromlist, s, state->sub_states)
{
reduce_outer_joins_state *sub_state = lfirst(s);
@@ -919,20 +919,20 @@ simplify_jointree(Query *parse, Node *jtnode)
* from_collapse_limit.
*/
FromExpr *subf = (FromExpr *) child;
int childlen = length(subf->fromlist);
int myothers = length(newlist) + children_remaining;
int childlen = list_length(subf->fromlist);
int myothers = list_length(newlist) + children_remaining;
if (childlen <= 1 ||
(childlen + myothers) <= from_collapse_limit)
{
newlist = nconc(newlist, subf->fromlist);
newlist = list_concat(newlist, subf->fromlist);
/*
* By now, the quals have been converted to
* implicit-AND lists, so we just need to join the
* lists. NOTE: we put the pulled-up quals first.
*/
f->quals = (Node *) nconc((List *) subf->quals,
f->quals = (Node *) list_concat((List *) subf->quals,
(List *) f->quals);
}
else
@@ -963,11 +963,11 @@ simplify_jointree(Query *parse, Node *jtnode)
rightlen;
if (j->larg && IsA(j->larg, FromExpr))
leftlen = length(((FromExpr *) j->larg)->fromlist);
leftlen = list_length(((FromExpr *) j->larg)->fromlist);
else
leftlen = 1;
if (j->rarg && IsA(j->rarg, FromExpr))
rightlen = length(((FromExpr *) j->rarg)->fromlist);
rightlen = list_length(((FromExpr *) j->rarg)->fromlist);
else
rightlen = 1;
if ((leftlen + rightlen) <= join_collapse_limit)
@@ -985,22 +985,22 @@ simplify_jointree(Query *parse, Node *jtnode)
f->quals = subf->quals;
}
else
f->fromlist = makeList1(j->larg);
f->fromlist = list_make1(j->larg);
if (j->rarg && IsA(j->rarg, FromExpr))
{
FromExpr *subf = (FromExpr *) j->rarg;
f->fromlist = nconc(f->fromlist,
subf->fromlist);
f->quals = (Node *) nconc((List *) f->quals,
f->fromlist = list_concat(f->fromlist,
subf->fromlist);
f->quals = (Node *) list_concat((List *) f->quals,
(List *) subf->quals);
}
else
f->fromlist = lappend(f->fromlist, j->rarg);
/* pulled-up quals first */
f->quals = (Node *) nconc((List *) f->quals,
f->quals = (Node *) list_concat((List *) f->quals,
(List *) j->quals);
return (Node *) f;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepqual.c,v 1.42 2004/05/26 04:41:26 neilc Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepqual.c,v 1.43 2004/05/30 23:40:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -445,7 +445,7 @@ process_duplicate_ors(List *orlist)
if (orlist == NIL)
return NULL; /* probably can't happen */
if (length(orlist) == 1) /* single-expression OR (can this happen?) */
if (list_length(orlist) == 1) /* single-expression OR (can this happen?) */
return linitial(orlist);
/*
@@ -461,7 +461,7 @@ process_duplicate_ors(List *orlist)
if (and_clause((Node *) clause))
{
List *subclauses = ((BoolExpr *) clause)->args;
int nclauses = length(subclauses);
int nclauses = list_length(subclauses);
if (reference == NIL || nclauses < num_subclauses)
{
@@ -471,7 +471,7 @@ process_duplicate_ors(List *orlist)
}
else
{
reference = makeList1(clause);
reference = list_make1(clause);
break;
}
}
@@ -479,7 +479,7 @@ process_duplicate_ors(List *orlist)
/*
* Just in case, eliminate any duplicates in the reference list.
*/
reference = set_union(NIL, reference);
reference = list_union(NIL, reference);
/*
* Check each element of the reference list to see if it's in all the
@@ -498,7 +498,7 @@ process_duplicate_ors(List *orlist)
if (and_clause((Node *) clause))
{
if (!member(refclause, ((BoolExpr *) clause)->args))
if (!list_member(((BoolExpr *) clause)->args, refclause))
{
win = false;
break;
@@ -531,7 +531,7 @@ process_duplicate_ors(List *orlist)
* (A AND B) OR (A), which can be reduced to just A --- that is, the
* additional conditions in other arms of the OR are irrelevant.
*
* Note that because we use set_difference, any multiple occurrences of
* Note that because we use list_difference, any multiple occurrences of
* a winning clause in an AND sub-clause will be removed automatically.
*/
neworlist = NIL;
@@ -543,10 +543,10 @@ process_duplicate_ors(List *orlist)
{
List *subclauses = ((BoolExpr *) clause)->args;
subclauses = set_difference(subclauses, winners);
subclauses = list_difference(subclauses, winners);
if (subclauses != NIL)
{
if (length(subclauses) == 1)
if (list_length(subclauses) == 1)
neworlist = lappend(neworlist, linitial(subclauses));
else
neworlist = lappend(neworlist, make_andclause(subclauses));
@@ -559,7 +559,7 @@ process_duplicate_ors(List *orlist)
}
else
{
if (!member(clause, winners))
if (!list_member(winners, clause))
neworlist = lappend(neworlist, clause);
else
{
@@ -577,7 +577,7 @@ process_duplicate_ors(List *orlist)
*/
if (neworlist != NIL)
{
if (length(neworlist) == 1)
if (list_length(neworlist) == 1)
winners = lappend(winners, linitial(neworlist));
else
winners = lappend(winners, make_orclause(pull_ors(neworlist)));
@@ -587,7 +587,7 @@ process_duplicate_ors(List *orlist)
* And return the constructed AND clause, again being wary of a single
* element and AND/OR flatness.
*/
if (length(winners) == 1)
if (list_length(winners) == 1)
return (Expr *) linitial(winners);
else
return make_andclause(pull_ands(winners));

View File

@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/prep/preptlist.c,v 1.67 2004/05/26 04:41:26 neilc Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/prep/preptlist.c,v 1.68 2004/05/30 23:40:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -79,7 +79,7 @@ preprocess_targetlist(List *tlist,
Resdom *resdom;
Var *var;
resdom = makeResdom(length(tlist) + 1,
resdom = makeResdom(list_length(tlist) + 1,
TIDOID,
-1,
pstrdup("ctid"),
@@ -94,7 +94,7 @@ preprocess_targetlist(List *tlist,
* modify the original tlist (is this really necessary?).
*/
if (command_type == CMD_DELETE)
tlist = listCopy(tlist);
tlist = list_copy(tlist);
tlist = lappend(tlist, makeTargetEntry(resdom, (Expr *) var));
}

View File

@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.111 2004/05/26 04:41:26 neilc Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.112 2004/05/30 23:40:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -235,10 +235,10 @@ generate_union_plan(SetOperationStmt *op, Query *parse,
* generate only one Append and Sort for the lot. Recurse to find
* such nodes and compute their children's plans.
*/
planlist = nconc(recurse_union_children(op->larg, parse,
op, refnames_tlist),
recurse_union_children(op->rarg, parse,
op, refnames_tlist));
planlist = list_concat(recurse_union_children(op->larg, parse,
op, refnames_tlist),
recurse_union_children(op->rarg, parse,
op, refnames_tlist));
/*
* Generate tlist for Append plan node.
@@ -303,7 +303,7 @@ generate_nonunion_plan(SetOperationStmt *op, Query *parse,
op->colTypes, false, 1,
refnames_tlist,
&child_sortclauses);
planlist = makeList2(lplan, rplan);
planlist = list_make2(lplan, rplan);
/*
* Generate tlist for Append plan node.
@@ -349,7 +349,7 @@ generate_nonunion_plan(SetOperationStmt *op, Query *parse,
cmd = SETOPCMD_INTERSECT; /* keep compiler quiet */
break;
}
plan = (Plan *) make_setop(cmd, plan, sortList, length(op->colTypes) + 1);
plan = (Plan *) make_setop(cmd, plan, sortList, list_length(op->colTypes) + 1);
*sortClauses = sortList;
@@ -375,15 +375,15 @@ recurse_union_children(Node *setOp, Query *parse,
if (op->op == top_union->op &&
(op->all == top_union->all || op->all) &&
equalo(op->colTypes, top_union->colTypes))
equal(op->colTypes, top_union->colTypes))
{
/* Same UNION, so fold children into parent's subplan list */
return nconc(recurse_union_children(op->larg, parse,
top_union,
refnames_tlist),
recurse_union_children(op->rarg, parse,
top_union,
refnames_tlist));
return list_concat(recurse_union_children(op->larg, parse,
top_union,
refnames_tlist),
recurse_union_children(op->rarg, parse,
top_union,
refnames_tlist));
}
}
@@ -397,10 +397,10 @@ recurse_union_children(Node *setOp, Query *parse,
* we have an EXCEPT or INTERSECT as child, else there won't be
* resjunk anyway.
*/
return makeList1(recurse_set_operations(setOp, parse,
top_union->colTypes, false,
-1, refnames_tlist,
&child_sortclauses));
return list_make1(recurse_set_operations(setOp, parse,
top_union->colTypes, false,
-1, refnames_tlist,
&child_sortclauses));
}
/*
@@ -430,7 +430,7 @@ generate_setop_tlist(List *colTypes, int flag,
k = list_head(refnames_tlist);
foreach(i, colTypes)
{
Oid colType = lfirsto(i);
Oid colType = lfirst_oid(i);
TargetEntry *inputtle = (TargetEntry *) lfirst(j);
TargetEntry *reftle = (TargetEntry *) lfirst(k);
int32 colTypmod;
@@ -536,7 +536,7 @@ generate_append_tlist(List *colTypes, bool flag,
* If the inputs all agree on type and typmod of a particular column, use
* that typmod; else use -1. (+1 here in case of zero columns.)
*/
colTypmods = (int32 *) palloc(length(colTypes) * sizeof(int32) + 1);
colTypmods = (int32 *) palloc(list_length(colTypes) * sizeof(int32) + 1);
foreach(planl, input_plans)
{
@@ -577,7 +577,7 @@ generate_append_tlist(List *colTypes, bool flag,
colindex = 0;
forboth(curColType, colTypes, ref_tl_item, refnames_tlist)
{
Oid colType = lfirsto(curColType);
Oid colType = lfirst_oid(curColType);
int32 colTypmod = colTypmods[colindex++];
TargetEntry *reftle = (TargetEntry *) lfirst(ref_tl_item);
@@ -663,7 +663,7 @@ List *
find_all_inheritors(Oid parentrel)
{
List *examined_relids = NIL;
List *unexamined_relids = makeListo1(parentrel);
List *unexamined_relids = list_make1_oid(parentrel);
/*
* While the queue of unexamined relids is nonempty, remove the first
@@ -676,7 +676,7 @@ find_all_inheritors(Oid parentrel)
List *currentchildren;
unexamined_relids = list_delete_first(unexamined_relids);
examined_relids = lappendo(examined_relids, currentrel);
examined_relids = lappend_oid(examined_relids, currentrel);
currentchildren = find_inheritance_children(currentrel);
/*
@@ -686,8 +686,8 @@ find_all_inheritors(Oid parentrel)
* into an infinite loop, though theoretically there can't be any
* cycles in the inheritance graph anyway.)
*/
currentchildren = set_differenceo(currentchildren, examined_relids);
unexamined_relids = set_uniono(unexamined_relids, currentchildren);
currentchildren = list_difference_oid(currentchildren, examined_relids);
unexamined_relids = list_union_oid(unexamined_relids, currentchildren);
}
return examined_relids;
@@ -744,17 +744,17 @@ expand_inherited_rtentry(Query *parse, Index rti, bool dup_parent)
* case. This could happen despite above has_subclass() check, if
* table once had a child but no longer does.
*/
if (length(inhOIDs) < 2)
if (list_length(inhOIDs) < 2)
return NIL;
/* OK, it's an inheritance set; expand it */
if (dup_parent)
inhRTIs = NIL;
else
inhRTIs = makeListi1(rti); /* include original RTE in result */
inhRTIs = list_make1_int(rti); /* include original RTE in result */
foreach(l, inhOIDs)
{
Oid childOID = lfirsto(l);
Oid childOID = lfirst_oid(l);
RangeTblEntry *childrte;
Index childRTindex;
@@ -771,9 +771,9 @@ expand_inherited_rtentry(Query *parse, Index rti, bool dup_parent)
childrte = copyObject(rte);
childrte->relid = childOID;
parse->rtable = lappend(parse->rtable, childrte);
childRTindex = length(parse->rtable);
childRTindex = list_length(parse->rtable);
inhRTIs = lappendi(inhRTIs, childRTindex);
inhRTIs = lappend_int(inhRTIs, childRTindex);
}
return inhRTIs;