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:
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_eval.c,v 1.68 2004/05/26 04:41:20 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_eval.c,v 1.69 2004/05/30 23:40:27 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -175,8 +175,8 @@ gimme_tree(Gene *tour, int num_gene, GeqoEvalData *evaldata)
|
||||
|
||||
/* Get the next input relation and push it */
|
||||
cur_rel_index = (int) tour[rel_count];
|
||||
stack[stack_depth] = (RelOptInfo *) nth(cur_rel_index - 1,
|
||||
evaldata->initial_rels);
|
||||
stack[stack_depth] = (RelOptInfo *) list_nth(evaldata->initial_rels,
|
||||
cur_rel_index - 1);
|
||||
stack_depth++;
|
||||
|
||||
/*
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.115 2004/05/26 04:41:21 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.116 2004/05/30 23:40:28 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -88,7 +88,7 @@ make_one_rel(Query *root)
|
||||
/*
|
||||
* The result should join all the query's base rels.
|
||||
*/
|
||||
Assert(bms_num_members(rel->relids) == length(root->base_rel_list));
|
||||
Assert(bms_num_members(rel->relids) == list_length(root->base_rel_list));
|
||||
|
||||
return rel;
|
||||
}
|
||||
@@ -218,7 +218,7 @@ set_inherited_rel_pathlist(Query *root, RelOptInfo *rel,
|
||||
* XXX for now, can't handle inherited expansion of FOR UPDATE; can we
|
||||
* do better?
|
||||
*/
|
||||
if (intMember(parentRTindex, root->rowMarks))
|
||||
if (list_member_int(root->rowMarks, parentRTindex))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("SELECT FOR UPDATE is not supported for inheritance queries")));
|
||||
@@ -242,7 +242,7 @@ set_inherited_rel_pathlist(Query *root, RelOptInfo *rel,
|
||||
*/
|
||||
foreach(il, inheritlist)
|
||||
{
|
||||
int childRTindex = lfirsti(il);
|
||||
int childRTindex = lfirst_int(il);
|
||||
RangeTblEntry *childrte;
|
||||
Oid childOID;
|
||||
RelOptInfo *childrel;
|
||||
@@ -338,7 +338,7 @@ set_subquery_pathlist(Query *root, RelOptInfo *rel,
|
||||
|
||||
/* We need a workspace for keeping track of set-op type coercions */
|
||||
differentTypes = (bool *)
|
||||
palloc0((length(subquery->targetList) + 1) * sizeof(bool));
|
||||
palloc0((list_length(subquery->targetList) + 1) * sizeof(bool));
|
||||
|
||||
/*
|
||||
* If there are any restriction clauses that have been attached to the
|
||||
@@ -441,7 +441,7 @@ make_fromexpr_rel(Query *root, FromExpr *from)
|
||||
* dynamic-programming algorithm we must employ to consider all ways
|
||||
* of joining the child nodes.
|
||||
*/
|
||||
levels_needed = length(from->fromlist);
|
||||
levels_needed = list_length(from->fromlist);
|
||||
|
||||
if (levels_needed <= 0)
|
||||
return NULL; /* nothing to do? */
|
||||
@@ -546,7 +546,7 @@ make_one_rel_by_joins(Query *root, int levels_needed, List *initial_rels)
|
||||
*/
|
||||
if (joinitems[levels_needed] == NIL)
|
||||
elog(ERROR, "failed to build any %d-way joins", levels_needed);
|
||||
Assert(length(joinitems[levels_needed]) == 1);
|
||||
Assert(list_length(joinitems[levels_needed]) == 1);
|
||||
|
||||
rel = (RelOptInfo *) linitial(joinitems[levels_needed]);
|
||||
|
||||
@@ -770,7 +770,7 @@ qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual,
|
||||
}
|
||||
}
|
||||
|
||||
freeList(vars);
|
||||
list_free(vars);
|
||||
bms_free(tested);
|
||||
|
||||
return safe;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.66 2004/05/26 04:41:21 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.67 2004/05/30 23:40:28 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -131,7 +131,7 @@ clauselist_selectivity(Query *root,
|
||||
* behave in the simple way we are expecting.) Most of the tests
|
||||
* here can be done more efficiently with rinfo than without.
|
||||
*/
|
||||
if (is_opclause(clause) && length(((OpExpr *) clause)->args) == 2)
|
||||
if (is_opclause(clause) && list_length(((OpExpr *) clause)->args) == 2)
|
||||
{
|
||||
OpExpr *expr = (OpExpr *) clause;
|
||||
bool varonleft = true;
|
||||
@@ -480,8 +480,8 @@ clause_selectivity(Query *root,
|
||||
*/
|
||||
s1 = restriction_selectivity(root,
|
||||
BooleanEqualOperator,
|
||||
makeList2(var,
|
||||
makeBoolConst(true,
|
||||
list_make2(var,
|
||||
makeBoolConst(true,
|
||||
false)),
|
||||
varRelid);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.127 2004/05/26 04:41:21 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.128 2004/05/30 23:40:28 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -412,7 +412,7 @@ cost_tidscan(Path *path, Query *root,
|
||||
Cost startup_cost = 0;
|
||||
Cost run_cost = 0;
|
||||
Cost cpu_per_tuple;
|
||||
int ntuples = length(tideval);
|
||||
int ntuples = list_length(tideval);
|
||||
|
||||
/* Should only be applied to base relations */
|
||||
Assert(baserel->relid > 0);
|
||||
@@ -1063,7 +1063,7 @@ cost_hashjoin(HashPath *path, Query *root)
|
||||
outer_path->parent->width);
|
||||
double innerbytes = relation_byte_size(inner_path_rows,
|
||||
inner_path->parent->width);
|
||||
int num_hashclauses = length(hashclauses);
|
||||
int num_hashclauses = list_length(hashclauses);
|
||||
int virtualbuckets;
|
||||
int physicalbuckets;
|
||||
int numbatches;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.159 2004/05/26 04:41:21 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.160 2004/05/30 23:40:28 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1042,11 +1042,11 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
|
||||
Expr *nonnullarg = ((NullTest *) predicate)->arg;
|
||||
|
||||
if (is_opclause(clause) &&
|
||||
member(nonnullarg, ((OpExpr *) clause)->args) &&
|
||||
list_member(((OpExpr *) clause)->args, nonnullarg) &&
|
||||
op_strict(((OpExpr *) clause)->opno))
|
||||
return true;
|
||||
if (is_funcclause(clause) &&
|
||||
member(nonnullarg, ((FuncExpr *) clause)->args) &&
|
||||
list_member(((FuncExpr *) clause)->args, nonnullarg) &&
|
||||
func_strict(((FuncExpr *) clause)->funcid))
|
||||
return true;
|
||||
return false; /* we can't succeed below... */
|
||||
@@ -1624,9 +1624,9 @@ make_innerjoin_index_path(Query *root,
|
||||
* Note that we are making a pathnode for a single-scan indexscan;
|
||||
* therefore, indexinfo etc should be single-element lists.
|
||||
*/
|
||||
pathnode->indexinfo = makeList1(index);
|
||||
pathnode->indexclauses = makeList1(allclauses);
|
||||
pathnode->indexquals = makeList1(indexquals);
|
||||
pathnode->indexinfo = list_make1(index);
|
||||
pathnode->indexclauses = list_make1(allclauses);
|
||||
pathnode->indexquals = list_make1(indexquals);
|
||||
|
||||
pathnode->isjoininner = true;
|
||||
|
||||
@@ -1649,7 +1649,7 @@ make_innerjoin_index_path(Query *root,
|
||||
* Always assume the join type is JOIN_INNER; even if some of the join
|
||||
* clauses come from other contexts, that's not our problem.
|
||||
*/
|
||||
allclauses = set_ptrUnion(rel->baserestrictinfo, allclauses);
|
||||
allclauses = list_union_ptr(rel->baserestrictinfo, allclauses);
|
||||
pathnode->rows = rel->tuples *
|
||||
clauselist_selectivity(root,
|
||||
allclauses,
|
||||
@@ -1679,7 +1679,7 @@ flatten_clausegroups_list(List *clausegroups)
|
||||
|
||||
foreach(l, clausegroups)
|
||||
{
|
||||
allclauses = nconc(allclauses, listCopy((List *) lfirst(l)));
|
||||
allclauses = list_concat(allclauses, list_copy((List *) lfirst(l)));
|
||||
}
|
||||
return allclauses;
|
||||
}
|
||||
@@ -1711,7 +1711,7 @@ make_expr_from_indexclauses(List *indexclauses)
|
||||
orclauses = lappend(orclauses, make_ands_explicit(andlist));
|
||||
}
|
||||
|
||||
if (length(orclauses) > 1)
|
||||
if (list_length(orclauses) > 1)
|
||||
return make_orclause(orclauses);
|
||||
else
|
||||
return (Expr *) linitial(orclauses);
|
||||
@@ -2114,7 +2114,7 @@ expand_indexqual_condition(RestrictInfo *rinfo, Oid opclass)
|
||||
break;
|
||||
|
||||
default:
|
||||
result = makeList1(rinfo);
|
||||
result = list_make1(rinfo);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2209,7 +2209,7 @@ prefix_quals(Node *leftop, Oid opclass,
|
||||
elog(ERROR, "no = operator for opclass %u", opclass);
|
||||
expr = make_opclause(oproid, BOOLOID, false,
|
||||
(Expr *) leftop, (Expr *) prefix_const);
|
||||
result = makeList1(make_restrictinfo(expr, true, true));
|
||||
result = list_make1(make_restrictinfo(expr, true, true));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2224,7 +2224,7 @@ prefix_quals(Node *leftop, Oid opclass,
|
||||
elog(ERROR, "no >= operator for opclass %u", opclass);
|
||||
expr = make_opclause(oproid, BOOLOID, false,
|
||||
(Expr *) leftop, (Expr *) prefix_const);
|
||||
result = makeList1(make_restrictinfo(expr, true, true));
|
||||
result = list_make1(make_restrictinfo(expr, true, true));
|
||||
|
||||
/*-------
|
||||
* If we can create a string larger than the prefix, we can say
|
||||
@@ -2311,7 +2311,7 @@ network_prefix_quals(Node *leftop, Oid expr_op, Oid opclass, Datum rightop)
|
||||
(Expr *) leftop,
|
||||
(Expr *) makeConst(datatype, -1, opr1right,
|
||||
false, false));
|
||||
result = makeList1(make_restrictinfo(expr, true, true));
|
||||
result = list_make1(make_restrictinfo(expr, true, true));
|
||||
|
||||
/* create clause "key <= network_scan_last( rightop )" */
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.87 2004/05/26 04:41:22 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.88 2004/05/30 23:40:28 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -236,8 +236,8 @@ sort_inner_and_outer(Query *root,
|
||||
/* Make a pathkey list with this guy first. */
|
||||
if (l != list_head(all_pathkeys))
|
||||
cur_pathkeys = lcons(front_pathkey,
|
||||
lremove(front_pathkey,
|
||||
listCopy(all_pathkeys)));
|
||||
list_delete_ptr(list_copy(all_pathkeys),
|
||||
front_pathkey));
|
||||
else
|
||||
cur_pathkeys = all_pathkeys; /* no work at first one... */
|
||||
|
||||
@@ -254,7 +254,7 @@ sort_inner_and_outer(Query *root,
|
||||
|
||||
/* Forget it if can't use all the clauses in right/full join */
|
||||
if (useallclauses &&
|
||||
length(cur_mergeclauses) != length(mergeclause_list))
|
||||
list_length(cur_mergeclauses) != list_length(mergeclause_list))
|
||||
continue;
|
||||
|
||||
/*
|
||||
@@ -510,7 +510,7 @@ match_unsorted_outer(Query *root,
|
||||
else
|
||||
continue;
|
||||
}
|
||||
if (useallclauses && length(mergeclauses) != length(mergeclause_list))
|
||||
if (useallclauses && list_length(mergeclauses) != list_length(mergeclause_list))
|
||||
continue;
|
||||
|
||||
/* Compute the required ordering of the inner path */
|
||||
@@ -547,9 +547,9 @@ match_unsorted_outer(Query *root,
|
||||
* consider both cheap startup cost and cheap total cost. Ignore
|
||||
* inner_cheapest_total, since we already made a path with it.
|
||||
*/
|
||||
num_sortkeys = length(innersortkeys);
|
||||
num_sortkeys = list_length(innersortkeys);
|
||||
if (num_sortkeys > 1 && !useallclauses)
|
||||
trialsortkeys = listCopy(innersortkeys); /* need modifiable copy */
|
||||
trialsortkeys = list_copy(innersortkeys); /* need modifiable copy */
|
||||
else
|
||||
trialsortkeys = innersortkeys; /* won't really truncate */
|
||||
cheapest_startup_inner = NULL;
|
||||
@@ -565,7 +565,7 @@ match_unsorted_outer(Query *root,
|
||||
* 'sortkeycnt' innersortkeys. NB: trialsortkeys list is
|
||||
* modified destructively, which is why we made a copy...
|
||||
*/
|
||||
trialsortkeys = ltruncate(sortkeycnt, trialsortkeys);
|
||||
trialsortkeys = list_truncate(trialsortkeys, sortkeycnt);
|
||||
innerpath = get_cheapest_path_for_pathkeys(innerrel->pathlist,
|
||||
trialsortkeys,
|
||||
TOTAL_COST);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.68 2004/05/26 04:41:22 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.69 2004/05/30 23:40:28 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -121,7 +121,7 @@ make_rels_by_joins(Query *root, int level, List **joinrels)
|
||||
{
|
||||
RelOptInfo *jrel = (RelOptInfo *) lfirst(nr);
|
||||
|
||||
if (!ptrMember(jrel, result_rels))
|
||||
if (!list_member_ptr(result_rels, jrel))
|
||||
result_rels = lcons(jrel, result_rels);
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,7 @@ make_rels_by_joins(Query *root, int level, List **joinrels)
|
||||
jrel = make_join_rel(root, old_rel, new_rel,
|
||||
JOIN_INNER);
|
||||
/* Avoid making duplicate entries ... */
|
||||
if (jrel && !ptrMember(jrel, result_rels))
|
||||
if (jrel && !list_member_ptr(result_rels, jrel))
|
||||
result_rels = lcons(jrel, result_rels);
|
||||
break; /* need not consider more
|
||||
* joininfos */
|
||||
@@ -234,7 +234,7 @@ make_rels_by_joins(Query *root, int level, List **joinrels)
|
||||
{
|
||||
RelOptInfo *jrel = (RelOptInfo *) lfirst(nr);
|
||||
|
||||
if (!ptrMember(jrel, result_rels))
|
||||
if (!list_member_ptr(result_rels, jrel))
|
||||
result_rels = lcons(jrel, result_rels);
|
||||
}
|
||||
}
|
||||
@@ -308,7 +308,7 @@ make_rels_by_clause_joins(Query *root,
|
||||
* Avoid entering same joinrel into our output list more
|
||||
* than once.
|
||||
*/
|
||||
if (jrel && !ptrMember(jrel, result))
|
||||
if (jrel && !list_member_ptr(result, jrel))
|
||||
result = lcons(jrel, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.58 2004/05/26 04:41:22 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.59 2004/05/30 23:40:28 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -149,9 +149,9 @@ create_or_index_quals(Query *root, RelOptInfo *rel)
|
||||
*/
|
||||
newrinfos = make_restrictinfo_from_indexclauses(bestpath->indexclauses,
|
||||
true, true);
|
||||
Assert(length(newrinfos) == 1);
|
||||
Assert(list_length(newrinfos) == 1);
|
||||
or_rinfo = (RestrictInfo *) linitial(newrinfos);
|
||||
rel->baserestrictinfo = nconc(rel->baserestrictinfo, newrinfos);
|
||||
rel->baserestrictinfo = list_concat(rel->baserestrictinfo, newrinfos);
|
||||
|
||||
/*
|
||||
* Adjust the original OR clause's cached selectivity to compensate
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.57 2004/05/26 04:41:22 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.58 2004/05/30 23:40:28 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -126,8 +126,8 @@ add_equijoined_keys(Query *root, RestrictInfo *restrictinfo)
|
||||
while (cursetlink)
|
||||
{
|
||||
List *curset = (List *) lfirst(cursetlink);
|
||||
bool item1here = member(item1, curset);
|
||||
bool item2here = member(item2, curset);
|
||||
bool item1here = list_member(curset, item1);
|
||||
bool item2here = list_member(curset, item2);
|
||||
|
||||
/* must advance cursetlink before lremove possibly pfree's it */
|
||||
cursetlink = lnext(cursetlink);
|
||||
@@ -147,22 +147,22 @@ add_equijoined_keys(Query *root, RestrictInfo *restrictinfo)
|
||||
|
||||
/* Build the new set only when we know we must */
|
||||
if (newset == NIL)
|
||||
newset = makeList2(item1, item2);
|
||||
newset = list_make2(item1, item2);
|
||||
|
||||
/* Found a set to merge into our new set */
|
||||
newset = set_union(newset, curset);
|
||||
newset = list_union(newset, curset);
|
||||
|
||||
/*
|
||||
* Remove old set from equi_key_list.
|
||||
*/
|
||||
root->equi_key_list = lremove(curset, root->equi_key_list);
|
||||
freeList(curset); /* might as well recycle old cons cells */
|
||||
root->equi_key_list = list_delete_ptr(root->equi_key_list, curset);
|
||||
list_free(curset); /* might as well recycle old cons cells */
|
||||
}
|
||||
}
|
||||
|
||||
/* Build the new set only when we know we must */
|
||||
if (newset == NIL)
|
||||
newset = makeList2(item1, item2);
|
||||
newset = list_make2(item1, item2);
|
||||
|
||||
root->equi_key_list = lcons(newset, root->equi_key_list);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ generate_implied_equalities(Query *root)
|
||||
foreach(cursetlink, root->equi_key_list)
|
||||
{
|
||||
List *curset = (List *) lfirst(cursetlink);
|
||||
int nitems = length(curset);
|
||||
int nitems = list_length(curset);
|
||||
Relids *relids;
|
||||
bool have_consts;
|
||||
ListCell *ptr1;
|
||||
@@ -341,10 +341,10 @@ make_canonical_pathkey(Query *root, PathKeyItem *item)
|
||||
{
|
||||
List *curset = (List *) lfirst(cursetlink);
|
||||
|
||||
if (member(item, curset))
|
||||
if (list_member(curset, item))
|
||||
return curset;
|
||||
}
|
||||
newset = makeList1(item);
|
||||
newset = list_make1(item);
|
||||
root->equi_key_list = lcons(newset, root->equi_key_list);
|
||||
return newset;
|
||||
}
|
||||
@@ -383,7 +383,7 @@ canonicalize_pathkeys(Query *root, List *pathkeys)
|
||||
* canonicalized the keys, so that equivalent-key knowledge is
|
||||
* used when deciding if an item is redundant.
|
||||
*/
|
||||
if (!ptrMember(cpathkey, new_pathkeys))
|
||||
if (!list_member_ptr(new_pathkeys, cpathkey))
|
||||
new_pathkeys = lappend(new_pathkeys, cpathkey);
|
||||
}
|
||||
return new_pathkeys;
|
||||
@@ -408,8 +408,8 @@ count_canonical_peers(Query *root, PathKeyItem *item)
|
||||
{
|
||||
List *curset = (List *) lfirst(cursetlink);
|
||||
|
||||
if (member(item, curset))
|
||||
return length(curset) - 1;
|
||||
if (list_member(curset, item))
|
||||
return list_length(curset) - 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -443,8 +443,8 @@ compare_pathkeys(List *keys1, List *keys2)
|
||||
* input, but query root not accessible here...
|
||||
*/
|
||||
#ifdef NOT_USED
|
||||
Assert(ptrMember(subkey1, root->equi_key_list));
|
||||
Assert(ptrMember(subkey2, root->equi_key_list));
|
||||
Assert(list_member_ptr(root->equi_key_list, subkey1));
|
||||
Assert(list_member_ptr(root->equi_key_list, subkey2));
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -499,8 +499,8 @@ compare_noncanonical_pathkeys(List *keys1, List *keys2)
|
||||
List *subkey1 = (List *) lfirst(key1);
|
||||
List *subkey2 = (List *) lfirst(key2);
|
||||
|
||||
Assert(length(subkey1) == 1);
|
||||
Assert(length(subkey2) == 1);
|
||||
Assert(list_length(subkey1) == 1);
|
||||
Assert(list_length(subkey2) == 1);
|
||||
if (!equal(subkey1, subkey2))
|
||||
return PATHKEYS_DIFFERENT; /* no need to keep looking */
|
||||
}
|
||||
@@ -693,7 +693,7 @@ build_index_pathkeys(Query *root,
|
||||
* Eliminate redundant ordering info; could happen if query is
|
||||
* such that index keys are equijoined...
|
||||
*/
|
||||
if (!ptrMember(cpathkey, retval))
|
||||
if (!list_member_ptr(retval, cpathkey))
|
||||
retval = lappend(retval, cpathkey);
|
||||
|
||||
indexkeys++;
|
||||
@@ -752,7 +752,7 @@ build_subquery_pathkeys(Query *root, RelOptInfo *rel, Query *subquery)
|
||||
{
|
||||
List *retval = NIL;
|
||||
int retvallen = 0;
|
||||
int outer_query_keys = length(root->query_pathkeys);
|
||||
int outer_query_keys = list_length(root->query_pathkeys);
|
||||
List *sub_tlist = rel->subplan->targetlist;
|
||||
ListCell *i;
|
||||
|
||||
@@ -810,8 +810,7 @@ build_subquery_pathkeys(Query *root, RelOptInfo *rel, Query *subquery)
|
||||
score = count_canonical_peers(root, outer_item);
|
||||
/* +1 if it matches the proper query_pathkeys item */
|
||||
if (retvallen < outer_query_keys &&
|
||||
member(outer_item,
|
||||
nth(retvallen, root->query_pathkeys)))
|
||||
list_member(list_nth(root->query_pathkeys, retvallen), outer_item))
|
||||
score++;
|
||||
if (score > best_score)
|
||||
{
|
||||
@@ -836,7 +835,7 @@ build_subquery_pathkeys(Query *root, RelOptInfo *rel, Query *subquery)
|
||||
* Eliminate redundant ordering info; could happen if outer query
|
||||
* equijoins subquery keys...
|
||||
*/
|
||||
if (!ptrMember(cpathkey, retval))
|
||||
if (!list_member_ptr(retval, cpathkey))
|
||||
{
|
||||
retval = lappend(retval, cpathkey);
|
||||
retvallen++;
|
||||
@@ -920,7 +919,7 @@ make_pathkeys_for_sortclauses(List *sortclauses,
|
||||
* canonicalize_pathkeys() might replace it with a longer sublist
|
||||
* later.
|
||||
*/
|
||||
pathkeys = lappend(pathkeys, makeList1(pathkey));
|
||||
pathkeys = lappend(pathkeys, list_make1(pathkey));
|
||||
}
|
||||
return pathkeys;
|
||||
}
|
||||
@@ -1041,7 +1040,7 @@ find_mergeclauses_for_pathkeys(Query *root,
|
||||
*/
|
||||
if ((pathkey == restrictinfo->left_pathkey ||
|
||||
pathkey == restrictinfo->right_pathkey) &&
|
||||
!ptrMember(restrictinfo, mergeclauses))
|
||||
!list_member_ptr(mergeclauses, restrictinfo))
|
||||
{
|
||||
matched_restrictinfos = lappend(matched_restrictinfos,
|
||||
restrictinfo);
|
||||
@@ -1060,7 +1059,7 @@ find_mergeclauses_for_pathkeys(Query *root,
|
||||
* If we did find usable mergeclause(s) for this sort-key
|
||||
* position, add them to result list.
|
||||
*/
|
||||
mergeclauses = nconc(mergeclauses, matched_restrictinfos);
|
||||
mergeclauses = list_concat(mergeclauses, matched_restrictinfos);
|
||||
}
|
||||
|
||||
return mergeclauses;
|
||||
@@ -1124,7 +1123,7 @@ make_pathkeys_for_mergeclauses(Query *root,
|
||||
* pathkey, a simple ptrMember test is sufficient to detect
|
||||
* redundant keys.
|
||||
*/
|
||||
if (!ptrMember(pathkey, pathkeys))
|
||||
if (!list_member_ptr(pathkeys, pathkey))
|
||||
pathkeys = lappend(pathkeys, pathkey);
|
||||
}
|
||||
|
||||
@@ -1214,7 +1213,7 @@ pathkeys_useful_for_merging(Query *root, RelOptInfo *rel, List *pathkeys)
|
||||
*
|
||||
* Unlike merge pathkeys, this is an all-or-nothing affair: it does us
|
||||
* no good to order by just the first key(s) of the requested ordering.
|
||||
* So the result is always either 0 or length(root->query_pathkeys).
|
||||
* So the result is always either 0 or list_length(root->query_pathkeys).
|
||||
*/
|
||||
int
|
||||
pathkeys_useful_for_ordering(Query *root, List *pathkeys)
|
||||
@@ -1228,7 +1227,7 @@ pathkeys_useful_for_ordering(Query *root, List *pathkeys)
|
||||
if (pathkeys_contained_in(root->query_pathkeys, pathkeys))
|
||||
{
|
||||
/* It's useful ... or at least the first N keys are */
|
||||
return length(root->query_pathkeys);
|
||||
return list_length(root->query_pathkeys);
|
||||
}
|
||||
|
||||
return 0; /* path ordering not useful */
|
||||
@@ -1255,8 +1254,8 @@ truncate_useless_pathkeys(Query *root,
|
||||
* Note: not safe to modify input list destructively, but we can avoid
|
||||
* copying the list if we're not actually going to change it
|
||||
*/
|
||||
if (nuseful == length(pathkeys))
|
||||
if (nuseful == list_length(pathkeys))
|
||||
return pathkeys;
|
||||
else
|
||||
return ltruncate(nuseful, listCopy(pathkeys));
|
||||
return list_truncate(list_copy(pathkeys), nuseful);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/tidpath.c,v 1.19 2004/05/26 04:41:22 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/tidpath.c,v 1.20 2004/05/30 23:40:28 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -79,7 +79,7 @@ TidequalClause(int varno, OpExpr *node)
|
||||
|
||||
if (node->opno != TIDEqualOperator)
|
||||
return rnode;
|
||||
if (length(node->args) != 2)
|
||||
if (list_length(node->args) != 2)
|
||||
return rnode;
|
||||
arg1 = linitial(node->args);
|
||||
arg2 = lsecond(node->args);
|
||||
@@ -184,11 +184,11 @@ TidqualFromExpr(int varno, Expr *expr)
|
||||
node = (Node *) lfirst(l);
|
||||
frtn = TidqualFromExpr(varno, (Expr *) node);
|
||||
if (frtn)
|
||||
rlst = nconc(rlst, frtn);
|
||||
rlst = list_concat(rlst, frtn);
|
||||
else
|
||||
{
|
||||
if (rlst)
|
||||
freeList(rlst);
|
||||
list_free(rlst);
|
||||
rlst = NIL;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.170 2004/05/26 04:41:24 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.171 2004/05/30 23:40:28 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -395,7 +395,7 @@ create_join_plan(Query *root, JoinPath *best_path)
|
||||
*/
|
||||
if (get_loc_restrictinfo(best_path) != NIL)
|
||||
set_qpqual((Plan) plan,
|
||||
nconc(get_qpqual((Plan) plan),
|
||||
list_concat(get_qpqual((Plan) plan),
|
||||
get_actual_clauses(get_loc_restrictinfo(best_path))));
|
||||
#endif
|
||||
|
||||
@@ -548,12 +548,12 @@ create_unique_plan(Query *root, UniquePath *best_path)
|
||||
elog(ERROR, "could not find UniquePath in in_info_list");
|
||||
|
||||
/* set up to record positions of unique columns */
|
||||
numGroupCols = length(uniq_exprs);
|
||||
numGroupCols = list_length(uniq_exprs);
|
||||
groupColIdx = (AttrNumber *) palloc(numGroupCols * sizeof(AttrNumber));
|
||||
groupColPos = 0;
|
||||
/* not sure if tlist might be shared with other nodes, so copy */
|
||||
newtlist = copyObject(subplan->targetlist);
|
||||
nextresno = length(newtlist) + 1;
|
||||
nextresno = list_length(newtlist) + 1;
|
||||
newitems = false;
|
||||
|
||||
foreach(l, uniq_exprs)
|
||||
@@ -725,9 +725,9 @@ create_indexscan_plan(Query *root,
|
||||
* need to worry about the plain AND case. Also, pointer comparison
|
||||
* should be enough to determine RestrictInfo matches.
|
||||
*/
|
||||
Assert(length(best_path->indexclauses) == 1);
|
||||
scan_clauses = set_ptrUnion(scan_clauses,
|
||||
(List *) linitial(best_path->indexclauses));
|
||||
Assert(list_length(best_path->indexclauses) == 1);
|
||||
scan_clauses = list_union_ptr(scan_clauses,
|
||||
(List *) linitial(best_path->indexclauses));
|
||||
}
|
||||
|
||||
/* Reduce RestrictInfo list to bare expressions */
|
||||
@@ -766,7 +766,7 @@ create_indexscan_plan(Query *root,
|
||||
* added to qpqual. The upshot is that qpquals must contain scan_clauses
|
||||
* minus whatever appears in indxquals.
|
||||
*/
|
||||
if (length(indxquals) > 1)
|
||||
if (list_length(indxquals) > 1)
|
||||
{
|
||||
/*
|
||||
* Build an expression representation of the indexqual, expanding
|
||||
@@ -775,7 +775,7 @@ create_indexscan_plan(Query *root,
|
||||
* scan_clause are not great; perhaps we need more smarts here.)
|
||||
*/
|
||||
indxqual_or_expr = make_expr_from_indexclauses(indxquals);
|
||||
qpqual = set_difference(scan_clauses, makeList1(indxqual_or_expr));
|
||||
qpqual = list_difference(scan_clauses, list_make1(indxqual_or_expr));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -785,7 +785,7 @@ create_indexscan_plan(Query *root,
|
||||
* behavior.
|
||||
*/
|
||||
Assert(stripped_indxquals != NIL);
|
||||
qpqual = set_difference(scan_clauses, linitial(stripped_indxquals));
|
||||
qpqual = list_difference(scan_clauses, linitial(stripped_indxquals));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -950,7 +950,7 @@ create_nestloop_plan(Query *root,
|
||||
List *indexclauses = innerpath->indexclauses;
|
||||
|
||||
if (innerpath->isjoininner &&
|
||||
length(indexclauses) == 1) /* single indexscan? */
|
||||
list_length(indexclauses) == 1) /* single indexscan? */
|
||||
{
|
||||
joinrestrictclauses =
|
||||
select_nonredundant_join_clauses(root,
|
||||
@@ -1019,7 +1019,7 @@ create_mergejoin_plan(Query *root,
|
||||
* the list of quals that must be checked as qpquals.
|
||||
*/
|
||||
mergeclauses = get_actual_clauses(best_path->path_mergeclauses);
|
||||
joinclauses = set_difference(joinclauses, mergeclauses);
|
||||
joinclauses = list_difference(joinclauses, mergeclauses);
|
||||
|
||||
/*
|
||||
* Rearrange mergeclauses, if needed, so that the outer variable is
|
||||
@@ -1103,7 +1103,7 @@ create_hashjoin_plan(Query *root,
|
||||
* the list of quals that must be checked as qpquals.
|
||||
*/
|
||||
hashclauses = get_actual_clauses(best_path->path_hashclauses);
|
||||
joinclauses = set_difference(joinclauses, hashclauses);
|
||||
joinclauses = list_difference(joinclauses, hashclauses);
|
||||
|
||||
/*
|
||||
* Rearrange hashclauses, if needed, so that the outer variable is
|
||||
@@ -1248,7 +1248,7 @@ fix_indxqual_sublist(List *indexqual,
|
||||
|
||||
Assert(IsA(rinfo, RestrictInfo));
|
||||
clause = (OpExpr *) rinfo->clause;
|
||||
if (!IsA(clause, OpExpr) || length(clause->args) != 2)
|
||||
if (!IsA(clause, OpExpr) || list_length(clause->args) != 2)
|
||||
elog(ERROR, "indexqual clause is not binary opclause");
|
||||
|
||||
/*
|
||||
@@ -1287,9 +1287,9 @@ fix_indxqual_sublist(List *indexqual,
|
||||
get_op_opclass_properties(newclause->opno, opclass,
|
||||
&stratno, &stratsubtype, &recheck);
|
||||
|
||||
*strategy = lappendi(*strategy, stratno);
|
||||
*subtype = lappendo(*subtype, stratsubtype);
|
||||
*lossy = lappendi(*lossy, (int) recheck);
|
||||
*strategy = lappend_int(*strategy, stratno);
|
||||
*subtype = lappend_oid(*subtype, stratsubtype);
|
||||
*lossy = lappend_int(*lossy, (int) recheck);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1401,7 +1401,7 @@ get_switched_clauses(List *clauses, Relids outerrelids)
|
||||
temp->opfuncid = InvalidOid;
|
||||
temp->opresulttype = clause->opresulttype;
|
||||
temp->opretset = clause->opretset;
|
||||
temp->args = listCopy(clause->args);
|
||||
temp->args = list_copy(clause->args);
|
||||
/* Commute it --- note this modifies the temp node in-place. */
|
||||
CommuteClause(temp);
|
||||
t_list = lappend(t_list, temp);
|
||||
@@ -1839,8 +1839,8 @@ make_sort_from_pathkeys(Query *root, Plan *lefttree, List *pathkeys)
|
||||
AttrNumber *sortColIdx;
|
||||
Oid *sortOperators;
|
||||
|
||||
/* We will need at most length(pathkeys) sort columns; possibly less */
|
||||
numsortkeys = length(pathkeys);
|
||||
/* We will need at most list_length(pathkeys) sort columns; possibly less */
|
||||
numsortkeys = list_length(pathkeys);
|
||||
sortColIdx = (AttrNumber *) palloc(numsortkeys * sizeof(AttrNumber));
|
||||
sortOperators = (Oid *) palloc(numsortkeys * sizeof(Oid));
|
||||
|
||||
@@ -1888,7 +1888,7 @@ make_sort_from_pathkeys(Query *root, Plan *lefttree, List *pathkeys)
|
||||
if (!tlist_member(lfirst(k), tlist))
|
||||
break;
|
||||
}
|
||||
freeList(exprvars);
|
||||
list_free(exprvars);
|
||||
if (!k)
|
||||
break; /* found usable expression */
|
||||
}
|
||||
@@ -1907,7 +1907,7 @@ make_sort_from_pathkeys(Query *root, Plan *lefttree, List *pathkeys)
|
||||
/*
|
||||
* Add resjunk entry to input's tlist
|
||||
*/
|
||||
resdom = makeResdom(length(tlist) + 1,
|
||||
resdom = makeResdom(list_length(tlist) + 1,
|
||||
exprType(pathkey->key),
|
||||
exprTypmod(pathkey->key),
|
||||
NULL,
|
||||
@@ -1950,8 +1950,8 @@ make_sort_from_sortclauses(Query *root, List *sortcls, Plan *lefttree)
|
||||
AttrNumber *sortColIdx;
|
||||
Oid *sortOperators;
|
||||
|
||||
/* We will need at most length(sortcls) sort columns; possibly less */
|
||||
numsortkeys = length(sortcls);
|
||||
/* We will need at most list_length(sortcls) sort columns; possibly less */
|
||||
numsortkeys = list_length(sortcls);
|
||||
sortColIdx = (AttrNumber *) palloc(numsortkeys * sizeof(AttrNumber));
|
||||
sortOperators = (Oid *) palloc(numsortkeys * sizeof(Oid));
|
||||
|
||||
@@ -2003,8 +2003,8 @@ make_sort_from_groupcols(Query *root,
|
||||
AttrNumber *sortColIdx;
|
||||
Oid *sortOperators;
|
||||
|
||||
/* We will need at most length(groupcls) sort columns; possibly less */
|
||||
numsortkeys = length(groupcls);
|
||||
/* We will need at most list_length(groupcls) sort columns; possibly less */
|
||||
numsortkeys = list_length(groupcls);
|
||||
sortColIdx = (AttrNumber *) palloc(numsortkeys * sizeof(AttrNumber));
|
||||
sortOperators = (Oid *) palloc(numsortkeys * sizeof(Oid));
|
||||
|
||||
@@ -2207,7 +2207,7 @@ make_unique(Plan *lefttree, List *distinctList)
|
||||
{
|
||||
Unique *node = makeNode(Unique);
|
||||
Plan *plan = &node->plan;
|
||||
int numCols = length(distinctList);
|
||||
int numCols = list_length(distinctList);
|
||||
int keyno = 0;
|
||||
AttrNumber *uniqColIdx;
|
||||
ListCell *slitem;
|
||||
@@ -2264,7 +2264,7 @@ make_setop(SetOpCmd cmd, Plan *lefttree,
|
||||
{
|
||||
SetOp *node = makeNode(SetOp);
|
||||
Plan *plan = &node->plan;
|
||||
int numCols = length(distinctList);
|
||||
int numCols = list_length(distinctList);
|
||||
int keyno = 0;
|
||||
AttrNumber *dupColIdx;
|
||||
ListCell *slitem;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.99 2004/05/26 04:41:24 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.100 2004/05/30 23:40:29 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -121,7 +121,7 @@ build_base_rel_tlists(Query *root, List *final_tlist)
|
||||
if (tlist_vars != NIL)
|
||||
{
|
||||
add_vars_to_targetlist(root, tlist_vars, bms_make_singleton(0));
|
||||
freeList(tlist_vars);
|
||||
list_free(tlist_vars);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ mark_baserels_for_outer_join(Query *root, Relids rels, Relids outerrels)
|
||||
*/
|
||||
if (rel->outerjoinset == NULL)
|
||||
{
|
||||
if (intMember(relno, root->rowMarks))
|
||||
if (list_member_int(root->rowMarks, relno))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("SELECT FOR UPDATE cannot be applied to the nullable side of an outer join")));
|
||||
@@ -585,7 +585,7 @@ distribute_qual_to_rels(Query *root, Node *clause,
|
||||
*/
|
||||
vars = pull_var_clause(clause, false);
|
||||
add_vars_to_targetlist(root, vars, relids);
|
||||
freeList(vars);
|
||||
list_free(vars);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -705,8 +705,8 @@ process_implied_equality(Query *root,
|
||||
if (membership == BMS_SINGLETON)
|
||||
{
|
||||
/* delete it from local restrictinfo list */
|
||||
rel1->baserestrictinfo = lremove(restrictinfo,
|
||||
rel1->baserestrictinfo);
|
||||
rel1->baserestrictinfo = list_delete_ptr(rel1->baserestrictinfo,
|
||||
restrictinfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -728,7 +728,7 @@ process_implied_equality(Query *root,
|
||||
*/
|
||||
ltype = exprType(item1);
|
||||
rtype = exprType(item2);
|
||||
eq_operator = compatible_oper(makeList1(makeString("=")),
|
||||
eq_operator = compatible_oper(list_make1(makeString("=")),
|
||||
ltype, rtype, true);
|
||||
if (!HeapTupleIsValid(eq_operator))
|
||||
{
|
||||
@@ -854,11 +854,11 @@ qual_is_redundant(Query *root,
|
||||
* done. We give up when we can't expand the equalexprs list any
|
||||
* more.
|
||||
*/
|
||||
equalexprs = makeList1(newleft);
|
||||
equalexprs = list_make1(newleft);
|
||||
do
|
||||
{
|
||||
someadded = false;
|
||||
/* cannot use foreach here because of possible lremove */
|
||||
/* cannot use foreach here because of possible list_delete */
|
||||
olditem = list_head(oldquals);
|
||||
while (olditem)
|
||||
{
|
||||
@@ -867,12 +867,12 @@ qual_is_redundant(Query *root,
|
||||
Node *oldright = get_rightop(oldrinfo->clause);
|
||||
Node *newguy = NULL;
|
||||
|
||||
/* must advance olditem before lremove possibly pfree's it */
|
||||
/* must advance olditem before list_delete possibly pfree's it */
|
||||
olditem = lnext(olditem);
|
||||
|
||||
if (member(oldleft, equalexprs))
|
||||
if (list_member(equalexprs, oldleft))
|
||||
newguy = oldright;
|
||||
else if (member(oldright, equalexprs))
|
||||
else if (list_member(equalexprs, oldright))
|
||||
newguy = oldleft;
|
||||
else
|
||||
continue;
|
||||
@@ -884,7 +884,7 @@ qual_is_redundant(Query *root,
|
||||
/*
|
||||
* Remove this qual from list, since we don't need it anymore.
|
||||
*/
|
||||
oldquals = lremove(oldrinfo, oldquals);
|
||||
oldquals = list_delete_ptr(oldquals, oldrinfo);
|
||||
}
|
||||
} while (someadded);
|
||||
|
||||
@@ -917,7 +917,7 @@ check_mergejoinable(RestrictInfo *restrictinfo)
|
||||
|
||||
if (!is_opclause(clause))
|
||||
return;
|
||||
if (length(((OpExpr *) clause)->args) != 2)
|
||||
if (list_length(((OpExpr *) clause)->args) != 2)
|
||||
return;
|
||||
|
||||
opno = ((OpExpr *) clause)->opno;
|
||||
@@ -950,7 +950,7 @@ check_hashjoinable(RestrictInfo *restrictinfo)
|
||||
|
||||
if (!is_opclause(clause))
|
||||
return;
|
||||
if (length(((OpExpr *) clause)->args) != 2)
|
||||
if (list_length(((OpExpr *) clause)->args) != 2)
|
||||
return;
|
||||
|
||||
opno = ((OpExpr *) clause)->opno;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.170 2004/05/26 04:41:24 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.171 2004/05/30 23:40:29 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -131,7 +131,7 @@ planner(Query *parse, bool isCursor, int cursorOptions)
|
||||
}
|
||||
|
||||
/* executor wants to know total number of Params used overall */
|
||||
result_plan->nParamExec = length(PlannerParamList);
|
||||
result_plan->nParamExec = list_length(PlannerParamList);
|
||||
|
||||
/* final cleanup of the plan */
|
||||
set_plan_references(result_plan, parse->rtable);
|
||||
@@ -493,14 +493,14 @@ inheritance_planner(Query *parse, List *inheritlist)
|
||||
{
|
||||
int parentRTindex = parse->resultRelation;
|
||||
Oid parentOID = getrelid(parentRTindex, parse->rtable);
|
||||
int mainrtlength = length(parse->rtable);
|
||||
int mainrtlength = list_length(parse->rtable);
|
||||
List *subplans = NIL;
|
||||
List *tlist = NIL;
|
||||
ListCell *l;
|
||||
|
||||
foreach(l, inheritlist)
|
||||
{
|
||||
int childRTindex = lfirsti(l);
|
||||
int childRTindex = lfirst_int(l);
|
||||
Oid childOID = getrelid(childRTindex, parse->rtable);
|
||||
int subrtlength;
|
||||
Query *subquery;
|
||||
@@ -522,13 +522,13 @@ inheritance_planner(Query *parse, List *inheritlist)
|
||||
* XXX my goodness this is ugly. Really need to think about ways to
|
||||
* rein in planner's habit of scribbling on its input.
|
||||
*/
|
||||
subrtlength = length(subquery->rtable);
|
||||
subrtlength = list_length(subquery->rtable);
|
||||
if (subrtlength > mainrtlength)
|
||||
{
|
||||
List *subrt;
|
||||
|
||||
subrt = list_copy_tail(subquery->rtable, mainrtlength);
|
||||
parse->rtable = nconc(parse->rtable, subrt);
|
||||
parse->rtable = list_concat(parse->rtable, subrt);
|
||||
mainrtlength = subrtlength;
|
||||
}
|
||||
/* Save preprocessed tlist from first rel for use in Append */
|
||||
@@ -634,7 +634,7 @@ grouping_planner(Query *parse, double tuple_fraction)
|
||||
double dNumGroups = 0;
|
||||
long numGroups = 0;
|
||||
int numAggs = 0;
|
||||
int numGroupCols = length(parse->groupClause);
|
||||
int numGroupCols = list_length(parse->groupClause);
|
||||
bool use_hashed_grouping = false;
|
||||
|
||||
/* Preprocess targetlist in case we are inside an INSERT/UPDATE. */
|
||||
@@ -672,7 +672,7 @@ grouping_planner(Query *parse, double tuple_fraction)
|
||||
|
||||
foreach(l, parse->rowMarks)
|
||||
{
|
||||
Index rti = lfirsti(l);
|
||||
Index rti = lfirst_int(l);
|
||||
char *resname;
|
||||
Resdom *resdom;
|
||||
Var *var;
|
||||
@@ -680,7 +680,7 @@ grouping_planner(Query *parse, double tuple_fraction)
|
||||
|
||||
resname = (char *) palloc(32);
|
||||
snprintf(resname, 32, "ctid%u", rti);
|
||||
resdom = makeResdom(length(tlist) + 1,
|
||||
resdom = makeResdom(list_length(tlist) + 1,
|
||||
TIDOID,
|
||||
-1,
|
||||
resname,
|
||||
@@ -1421,7 +1421,7 @@ make_subplanTargetList(Query *parse,
|
||||
sub_tlist = flatten_tlist(tlist);
|
||||
extravars = pull_var_clause(parse->havingQual, false);
|
||||
sub_tlist = add_to_flat_tlist(sub_tlist, extravars);
|
||||
freeList(extravars);
|
||||
list_free(extravars);
|
||||
*need_tlist_eval = false; /* only eval if not flat tlist */
|
||||
|
||||
/*
|
||||
@@ -1430,7 +1430,7 @@ make_subplanTargetList(Query *parse,
|
||||
* already), and make an array showing where the group columns are in
|
||||
* the sub_tlist.
|
||||
*/
|
||||
numCols = length(parse->groupClause);
|
||||
numCols = list_length(parse->groupClause);
|
||||
if (numCols > 0)
|
||||
{
|
||||
int keyno = 0;
|
||||
@@ -1456,7 +1456,7 @@ make_subplanTargetList(Query *parse,
|
||||
}
|
||||
if (!sl)
|
||||
{
|
||||
te = makeTargetEntry(makeResdom(length(sub_tlist) + 1,
|
||||
te = makeTargetEntry(makeResdom(list_length(sub_tlist) + 1,
|
||||
exprType(groupexpr),
|
||||
exprTypmod(groupexpr),
|
||||
NULL,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.90 2004/05/26 04:41:24 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.91 2004/05/30 23:40:29 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -191,7 +191,7 @@ replace_outer_agg(Aggref *agg)
|
||||
pitem->abslevel = abslevel;
|
||||
|
||||
PlannerParamList = lappend(PlannerParamList, pitem);
|
||||
i = length(PlannerParamList) - 1;
|
||||
i = list_length(PlannerParamList) - 1;
|
||||
|
||||
retval = makeNode(Param);
|
||||
retval->paramkind = PARAM_EXEC;
|
||||
@@ -216,7 +216,7 @@ generate_new_param(Oid paramtype, int32 paramtypmod)
|
||||
|
||||
retval = makeNode(Param);
|
||||
retval->paramkind = PARAM_EXEC;
|
||||
retval->paramid = (AttrNumber) length(PlannerParamList);
|
||||
retval->paramid = (AttrNumber) list_length(PlannerParamList);
|
||||
retval->paramtype = paramtype;
|
||||
|
||||
pitem = (PlannerParamItem *) palloc(sizeof(PlannerParamItem));
|
||||
@@ -320,10 +320,10 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual)
|
||||
tmpset = bms_copy(plan->extParam);
|
||||
while ((paramid = bms_first_member(tmpset)) >= 0)
|
||||
{
|
||||
PlannerParamItem *pitem = nth(paramid, PlannerParamList);
|
||||
PlannerParamItem *pitem = list_nth(PlannerParamList, paramid);
|
||||
|
||||
if (pitem->abslevel == PlannerQueryLevel)
|
||||
node->parParam = lappendi(node->parParam, paramid);
|
||||
node->parParam = lappend_int(node->parParam, paramid);
|
||||
}
|
||||
bms_free(tmpset);
|
||||
|
||||
@@ -341,7 +341,7 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual)
|
||||
Param *prm;
|
||||
|
||||
prm = generate_new_param(BOOLOID, -1);
|
||||
node->setParam = makeListi1(prm->paramid);
|
||||
node->setParam = list_make1_int(prm->paramid);
|
||||
PlannerInitPlan = lappend(PlannerInitPlan, node);
|
||||
result = (Node *) prm;
|
||||
}
|
||||
@@ -352,7 +352,7 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual)
|
||||
|
||||
Assert(!te->resdom->resjunk);
|
||||
prm = generate_new_param(te->resdom->restype, te->resdom->restypmod);
|
||||
node->setParam = makeListi1(prm->paramid);
|
||||
node->setParam = list_make1_int(prm->paramid);
|
||||
PlannerInitPlan = lappend(PlannerInitPlan, node);
|
||||
result = (Node *) prm;
|
||||
}
|
||||
@@ -368,7 +368,7 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual)
|
||||
elog(ERROR, "could not find array type for datatype %s",
|
||||
format_type_be(te->resdom->restype));
|
||||
prm = generate_new_param(arraytype, -1);
|
||||
node->setParam = makeListi1(prm->paramid);
|
||||
node->setParam = list_make1_int(prm->paramid);
|
||||
PlannerInitPlan = lappend(PlannerInitPlan, node);
|
||||
result = (Node *) prm;
|
||||
}
|
||||
@@ -382,7 +382,7 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual)
|
||||
plan->targetlist,
|
||||
0,
|
||||
&node->paramIds);
|
||||
node->setParam = listCopy(node->paramIds);
|
||||
node->setParam = list_copy(node->paramIds);
|
||||
PlannerInitPlan = lappend(PlannerInitPlan, node);
|
||||
|
||||
/*
|
||||
@@ -390,7 +390,7 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual)
|
||||
* outer plan's expression tree; they are not kept in the initplan
|
||||
* node.
|
||||
*/
|
||||
if (length(exprs) > 1)
|
||||
if (list_length(exprs) > 1)
|
||||
result = (Node *) (node->useOr ? make_orclause(exprs) :
|
||||
make_andclause(exprs));
|
||||
else
|
||||
@@ -473,7 +473,7 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual)
|
||||
args = NIL;
|
||||
foreach(l, node->parParam)
|
||||
{
|
||||
PlannerParamItem *pitem = nth(lfirsti(l), PlannerParamList);
|
||||
PlannerParamItem *pitem = list_nth(PlannerParamList, lfirst_int(l));
|
||||
|
||||
/*
|
||||
* The Var or Aggref has already been adjusted to have the
|
||||
@@ -517,7 +517,7 @@ convert_sublink_opers(List *lefthand, List *operOids,
|
||||
|
||||
foreach(l, operOids)
|
||||
{
|
||||
Oid opid = lfirsto(l);
|
||||
Oid opid = lfirst_oid(l);
|
||||
Node *leftop = (Node *) lfirst(lefthand_item);
|
||||
TargetEntry *te = (TargetEntry *) lfirst(tlist_item);
|
||||
Node *rightop;
|
||||
@@ -547,7 +547,7 @@ convert_sublink_opers(List *lefthand, List *operOids,
|
||||
prm = generate_new_param(te->resdom->restype,
|
||||
te->resdom->restypmod);
|
||||
/* Record its ID */
|
||||
*righthandIds = lappendi(*righthandIds, prm->paramid);
|
||||
*righthandIds = lappend_int(*righthandIds, prm->paramid);
|
||||
rightop = (Node *) prm;
|
||||
}
|
||||
|
||||
@@ -603,7 +603,7 @@ subplan_is_hashable(SubLink *slink, SubPlan *node)
|
||||
*/
|
||||
if (slink->subLinkType != ANY_SUBLINK)
|
||||
return false;
|
||||
if (length(slink->operName) != 1 ||
|
||||
if (list_length(slink->operName) != 1 ||
|
||||
strcmp(strVal(linitial(slink->operName)), "=") != 0)
|
||||
return false;
|
||||
|
||||
@@ -640,7 +640,7 @@ subplan_is_hashable(SubLink *slink, SubPlan *node)
|
||||
*/
|
||||
foreach(l, slink->operOids)
|
||||
{
|
||||
Oid opid = lfirsto(l);
|
||||
Oid opid = lfirst_oid(l);
|
||||
HeapTuple tup;
|
||||
Form_pg_operator optup;
|
||||
|
||||
@@ -691,7 +691,7 @@ convert_IN_to_join(Query *parse, SubLink *sublink)
|
||||
*/
|
||||
if (sublink->subLinkType != ANY_SUBLINK)
|
||||
return NULL;
|
||||
if (length(sublink->operName) != 1 ||
|
||||
if (list_length(sublink->operName) != 1 ||
|
||||
strcmp(strVal(linitial(sublink->operName)), "=") != 0)
|
||||
return NULL;
|
||||
|
||||
@@ -731,7 +731,7 @@ convert_IN_to_join(Query *parse, SubLink *sublink)
|
||||
makeAlias("IN_subquery", NIL),
|
||||
false);
|
||||
parse->rtable = lappend(parse->rtable, rte);
|
||||
rtindex = length(parse->rtable);
|
||||
rtindex = list_length(parse->rtable);
|
||||
rtr = makeNode(RangeTblRef);
|
||||
rtr->rtindex = rtindex;
|
||||
parse->jointree->fromlist = lappend(parse->jointree->fromlist, rtr);
|
||||
@@ -874,7 +874,7 @@ process_sublinks_mutator(Node *node, bool *isTopQual)
|
||||
newarg = process_sublinks_mutator(lfirst(l),
|
||||
(void *) &locTopQual);
|
||||
if (and_clause(newarg))
|
||||
newargs = nconc(newargs, ((BoolExpr *) newarg)->args);
|
||||
newargs = list_concat(newargs, ((BoolExpr *) newarg)->args);
|
||||
else
|
||||
newargs = lappend(newargs, newarg);
|
||||
}
|
||||
@@ -896,7 +896,7 @@ process_sublinks_mutator(Node *node, bool *isTopQual)
|
||||
newarg = process_sublinks_mutator(lfirst(l),
|
||||
(void *) &locTopQual);
|
||||
if (or_clause(newarg))
|
||||
newargs = nconc(newargs, ((BoolExpr *) newarg)->args);
|
||||
newargs = list_concat(newargs, ((BoolExpr *) newarg)->args);
|
||||
else
|
||||
newargs = lappend(newargs, newarg);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.171 2004/05/26 04:41:27 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.172 2004/05/30 23:40:30 neilc Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -96,9 +96,9 @@ make_opclause(Oid opno, Oid opresulttype, bool opretset,
|
||||
expr->opresulttype = opresulttype;
|
||||
expr->opretset = opretset;
|
||||
if (rightop)
|
||||
expr->args = makeList2(leftop, rightop);
|
||||
expr->args = list_make2(leftop, rightop);
|
||||
else
|
||||
expr->args = makeList1(leftop);
|
||||
expr->args = list_make1(leftop);
|
||||
return (Expr *) expr;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ make_notclause(Expr *notclause)
|
||||
BoolExpr *expr = makeNode(BoolExpr);
|
||||
|
||||
expr->boolop = NOT_EXPR;
|
||||
expr->args = makeList1(notclause);
|
||||
expr->args = list_make1(notclause);
|
||||
return (Expr *) expr;
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ make_and_qual(Node *qual1, Node *qual2)
|
||||
return qual2;
|
||||
if (qual2 == NULL)
|
||||
return qual1;
|
||||
return (Node *) make_andclause(makeList2(qual1, qual2));
|
||||
return (Node *) make_andclause(list_make2(qual1, qual2));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -278,7 +278,7 @@ make_ands_explicit(List *andclauses)
|
||||
{
|
||||
if (andclauses == NIL)
|
||||
return (Expr *) makeBoolConst(true, false);
|
||||
else if (length(andclauses) == 1)
|
||||
else if (list_length(andclauses) == 1)
|
||||
return (Expr *) linitial(andclauses);
|
||||
else
|
||||
return make_andclause(andclauses);
|
||||
@@ -302,7 +302,7 @@ make_ands_implicit(Expr *clause)
|
||||
DatumGetBool(((Const *) clause)->constvalue))
|
||||
return NIL; /* constant TRUE input -> NIL list */
|
||||
else
|
||||
return makeList1(clause);
|
||||
return list_make1(clause);
|
||||
}
|
||||
|
||||
|
||||
@@ -599,7 +599,7 @@ contain_mutable_functions_walker(Node *node, void *context)
|
||||
|
||||
foreach(opid, sublink->operOids)
|
||||
{
|
||||
if (op_volatile(lfirsto(opid)) != PROVOLATILE_IMMUTABLE)
|
||||
if (op_volatile(lfirst_oid(opid)) != PROVOLATILE_IMMUTABLE)
|
||||
return true;
|
||||
}
|
||||
/* else fall through to check args */
|
||||
@@ -682,7 +682,7 @@ contain_volatile_functions_walker(Node *node, void *context)
|
||||
|
||||
foreach(opid, sublink->operOids)
|
||||
{
|
||||
if (op_volatile(lfirsto(opid)) == PROVOLATILE_VOLATILE)
|
||||
if (op_volatile(lfirst_oid(opid)) == PROVOLATILE_VOLATILE)
|
||||
return true;
|
||||
}
|
||||
/* else fall through to check args */
|
||||
@@ -982,7 +982,7 @@ CommuteClause(OpExpr *clause)
|
||||
|
||||
/* Sanity checks: caller is at fault if these fail */
|
||||
if (!is_opclause(clause) ||
|
||||
length(clause->args) != 2)
|
||||
list_length(clause->args) != 2)
|
||||
elog(ERROR, "cannot commute non-binary-operator clause");
|
||||
|
||||
opoid = get_commutator(clause->opno);
|
||||
@@ -1281,7 +1281,7 @@ eval_const_expressions_mutator(Node *node, List *active_fns)
|
||||
if (newargs == NIL)
|
||||
return makeBoolConst(false, false);
|
||||
/* If only one nonconst-or-NULL input, it's the result */
|
||||
if (length(newargs) == 1)
|
||||
if (list_length(newargs) == 1)
|
||||
return (Node *) linitial(newargs);
|
||||
/* Else we still need an OR node */
|
||||
return (Node *) make_orclause(newargs);
|
||||
@@ -1302,13 +1302,13 @@ eval_const_expressions_mutator(Node *node, List *active_fns)
|
||||
if (newargs == NIL)
|
||||
return makeBoolConst(true, false);
|
||||
/* If only one nonconst-or-NULL input, it's the result */
|
||||
if (length(newargs) == 1)
|
||||
if (list_length(newargs) == 1)
|
||||
return (Node *) linitial(newargs);
|
||||
/* Else we still need an AND node */
|
||||
return (Node *) make_andclause(newargs);
|
||||
}
|
||||
case NOT_EXPR:
|
||||
Assert(length(args) == 1);
|
||||
Assert(list_length(args) == 1);
|
||||
if (IsA(linitial(args), Const))
|
||||
{
|
||||
Const *const_input = (Const *) linitial(args);
|
||||
@@ -1570,8 +1570,8 @@ eval_const_expressions_mutator(Node *node, List *active_fns)
|
||||
RowExpr *rowexpr = (RowExpr *) arg;
|
||||
|
||||
if (fselect->fieldnum > 0 &&
|
||||
fselect->fieldnum <= length(rowexpr->args))
|
||||
return (Node *) nth(fselect->fieldnum - 1, rowexpr->args);
|
||||
fselect->fieldnum <= list_length(rowexpr->args))
|
||||
return (Node *) list_nth(rowexpr->args, fselect->fieldnum - 1);
|
||||
}
|
||||
newfselect = makeNode(FieldSelect);
|
||||
newfselect->arg = (Expr *) arg;
|
||||
@@ -1640,9 +1640,9 @@ simplify_or_arguments(List *args, bool *haveNull, bool *forceTrue)
|
||||
}
|
||||
else if (or_clause(arg))
|
||||
{
|
||||
newargs = nconc(newargs,
|
||||
simplify_or_arguments(((BoolExpr *) arg)->args,
|
||||
haveNull, forceTrue));
|
||||
newargs = list_concat(newargs,
|
||||
simplify_or_arguments(((BoolExpr *) arg)->args,
|
||||
haveNull, forceTrue));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1701,9 +1701,9 @@ simplify_and_arguments(List *args, bool *haveNull, bool *forceFalse)
|
||||
}
|
||||
else if (and_clause(arg))
|
||||
{
|
||||
newargs = nconc(newargs,
|
||||
simplify_and_arguments(((BoolExpr *) arg)->args,
|
||||
haveNull, forceFalse));
|
||||
newargs = list_concat(newargs,
|
||||
simplify_and_arguments(((BoolExpr *) arg)->args,
|
||||
haveNull, forceFalse));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1880,11 +1880,11 @@ inline_function(Oid funcid, Oid result_type, List *args,
|
||||
if (funcform->prolang != SQLlanguageId ||
|
||||
funcform->prosecdef ||
|
||||
funcform->proretset ||
|
||||
funcform->pronargs != length(args))
|
||||
funcform->pronargs != list_length(args))
|
||||
return NULL;
|
||||
|
||||
/* Check for recursive function, and give up trying to expand if so */
|
||||
if (oidMember(funcid, active_fns))
|
||||
if (list_member_oid(active_fns, funcid))
|
||||
return NULL;
|
||||
|
||||
/* Check permission to call function (fail later, if not) */
|
||||
@@ -1899,7 +1899,7 @@ inline_function(Oid funcid, Oid result_type, List *args,
|
||||
argtypes[i] == ANYELEMENTOID)
|
||||
{
|
||||
polymorphic = true;
|
||||
argtypes[i] = exprType((Node *) nth(i, args));
|
||||
argtypes[i] = exprType((Node *) list_nth(args, i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1943,13 +1943,13 @@ inline_function(Oid funcid, Oid result_type, List *args,
|
||||
* more than one command in the function body.
|
||||
*/
|
||||
raw_parsetree_list = pg_parse_query(src);
|
||||
if (length(raw_parsetree_list) != 1)
|
||||
if (list_length(raw_parsetree_list) != 1)
|
||||
goto fail;
|
||||
|
||||
querytree_list = parse_analyze(linitial(raw_parsetree_list),
|
||||
argtypes, funcform->pronargs);
|
||||
|
||||
if (length(querytree_list) != 1)
|
||||
if (list_length(querytree_list) != 1)
|
||||
goto fail;
|
||||
|
||||
querytree = (Query *) linitial(querytree_list);
|
||||
@@ -1973,7 +1973,7 @@ inline_function(Oid funcid, Oid result_type, List *args,
|
||||
querytree->limitOffset ||
|
||||
querytree->limitCount ||
|
||||
querytree->setOperations ||
|
||||
length(querytree->targetList) != 1)
|
||||
list_length(querytree->targetList) != 1)
|
||||
goto fail;
|
||||
|
||||
newexpr = (Node *) ((TargetEntry *) linitial(querytree->targetList))->expr;
|
||||
@@ -2048,7 +2048,7 @@ inline_function(Oid funcid, Oid result_type, List *args,
|
||||
*/
|
||||
if (contain_subplans(param))
|
||||
goto fail;
|
||||
cost_qual_eval(&eval_cost, makeList1(param));
|
||||
cost_qual_eval(&eval_cost, list_make1(param));
|
||||
if (eval_cost.startup + eval_cost.per_tuple >
|
||||
10 * cpu_operator_cost)
|
||||
goto fail;
|
||||
@@ -2078,7 +2078,7 @@ inline_function(Oid funcid, Oid result_type, List *args,
|
||||
* add the current function to the context list of active functions.
|
||||
*/
|
||||
newexpr = eval_const_expressions_mutator(newexpr,
|
||||
lconso(funcid, active_fns));
|
||||
lcons_oid(funcid, active_fns));
|
||||
|
||||
error_context_stack = sqlerrcontext.previous;
|
||||
|
||||
@@ -2129,7 +2129,7 @@ substitute_actual_parameters_mutator(Node *node,
|
||||
|
||||
/* Select the appropriate actual arg and replace the Param with it */
|
||||
/* We don't need to copy at this time (it'll get done later) */
|
||||
return nth(param->paramid - 1, context->args);
|
||||
return list_nth(context->args, param->paramid - 1);
|
||||
}
|
||||
return expression_tree_mutator(node, substitute_actual_parameters_mutator,
|
||||
(void *) context);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/joininfo.c,v 1.38 2004/05/26 04:41:27 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/joininfo.c,v 1.39 2004/05/30 23:40:31 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -162,9 +162,9 @@ remove_join_clause_from_rels(Query *root,
|
||||
* Remove the restrictinfo from the list. Pointer comparison is
|
||||
* sufficient.
|
||||
*/
|
||||
Assert(ptrMember(restrictinfo, joininfo->jinfo_restrictinfo));
|
||||
joininfo->jinfo_restrictinfo = lremove(restrictinfo,
|
||||
joininfo->jinfo_restrictinfo);
|
||||
Assert(list_member_ptr(joininfo->jinfo_restrictinfo, restrictinfo));
|
||||
joininfo->jinfo_restrictinfo = list_delete_ptr(joininfo->jinfo_restrictinfo,
|
||||
restrictinfo);
|
||||
bms_free(unjoined_relids);
|
||||
}
|
||||
bms_free(tmprelids);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.105 2004/05/26 04:41:27 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.106 2004/05/30 23:40:31 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -452,9 +452,9 @@ create_index_path(Query *root,
|
||||
* We are making a pathnode for a single-scan indexscan; therefore,
|
||||
* indexinfo etc should be single-element lists.
|
||||
*/
|
||||
pathnode->indexinfo = makeList1(index);
|
||||
pathnode->indexclauses = makeList1(restriction_clauses);
|
||||
pathnode->indexquals = makeList1(indexquals);
|
||||
pathnode->indexinfo = list_make1(index);
|
||||
pathnode->indexclauses = list_make1(restriction_clauses);
|
||||
pathnode->indexquals = list_make1(indexquals);
|
||||
|
||||
/* It's not an innerjoin path. */
|
||||
pathnode->isjoininner = false;
|
||||
@@ -686,12 +686,12 @@ create_unique_path(Query *root, RelOptInfo *rel, Path *subpath)
|
||||
if (sub_targetlist)
|
||||
{
|
||||
pathnode->rows = estimate_num_groups(root, sub_targetlist, rel->rows);
|
||||
numCols = length(sub_targetlist);
|
||||
numCols = list_length(sub_targetlist);
|
||||
}
|
||||
else
|
||||
{
|
||||
pathnode->rows = rel->rows;
|
||||
numCols = length(FastListValue(&rel->reltargetlist));
|
||||
numCols = list_length(FastListValue(&rel->reltargetlist));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.92 2004/05/26 04:41:27 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.93 2004/05/30 23:40:31 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -82,7 +82,7 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel)
|
||||
|
||||
foreach(l, indexoidlist)
|
||||
{
|
||||
Oid indexoid = lfirsto(l);
|
||||
Oid indexoid = lfirst_oid(l);
|
||||
Relation indexRelation;
|
||||
Form_pg_index index;
|
||||
IndexOptInfo *info;
|
||||
@@ -158,7 +158,7 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel)
|
||||
indexinfos = lcons(info, indexinfos);
|
||||
}
|
||||
|
||||
freeList(indexoidlist);
|
||||
list_free(indexoidlist);
|
||||
}
|
||||
|
||||
rel->indexlist = indexinfos;
|
||||
@@ -338,7 +338,7 @@ find_inheritance_children(Oid inhparent)
|
||||
while ((inheritsTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
||||
{
|
||||
inhrelid = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhrelid;
|
||||
list = lappendo(list, inhrelid);
|
||||
list = lappend_oid(list, inhrelid);
|
||||
}
|
||||
heap_endscan(scan);
|
||||
heap_close(relation, AccessShareLock);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.57 2004/05/26 04:41:27 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.58 2004/05/30 23:40:31 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -162,7 +162,7 @@ make_base_rel(Query *root, int relid)
|
||||
/* Subquery or function --- need only set up attr range */
|
||||
/* Note: 0 is included in range to support whole-row Vars */
|
||||
rel->min_attr = 0;
|
||||
rel->max_attr = length(rte->eref->colnames);
|
||||
rel->max_attr = list_length(rte->eref->colnames);
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "unrecognized RTE kind: %d",
|
||||
@@ -446,10 +446,10 @@ build_joinrel_restrictlist(Query *root,
|
||||
/*
|
||||
* Collect all the clauses that syntactically belong at this level.
|
||||
*/
|
||||
rlist = nconc(subbuild_joinrel_restrictlist(joinrel,
|
||||
outer_rel->joininfo),
|
||||
subbuild_joinrel_restrictlist(joinrel,
|
||||
inner_rel->joininfo));
|
||||
rlist = list_concat(subbuild_joinrel_restrictlist(joinrel,
|
||||
outer_rel->joininfo),
|
||||
subbuild_joinrel_restrictlist(joinrel,
|
||||
inner_rel->joininfo));
|
||||
|
||||
/*
|
||||
* Eliminate duplicate and redundant clauses.
|
||||
@@ -462,7 +462,7 @@ build_joinrel_restrictlist(Query *root,
|
||||
*/
|
||||
result = remove_redundant_join_clauses(root, rlist, jointype);
|
||||
|
||||
freeList(rlist);
|
||||
list_free(rlist);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -496,8 +496,8 @@ subbuild_joinrel_restrictlist(RelOptInfo *joinrel,
|
||||
* We must copy the list to avoid disturbing the input relation,
|
||||
* but we can use a shallow copy.
|
||||
*/
|
||||
restrictlist = nconc(restrictlist,
|
||||
listCopy(joininfo->jinfo_restrictinfo));
|
||||
restrictlist = list_concat(restrictlist,
|
||||
list_copy(joininfo->jinfo_restrictinfo));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -549,8 +549,8 @@ subbuild_joinrel_joinlist(RelOptInfo *joinrel,
|
||||
|
||||
new_joininfo = make_joininfo_node(joinrel, new_unjoined_relids);
|
||||
new_joininfo->jinfo_restrictinfo =
|
||||
set_ptrUnion(new_joininfo->jinfo_restrictinfo,
|
||||
joininfo->jinfo_restrictinfo);
|
||||
list_union_ptr(new_joininfo->jinfo_restrictinfo,
|
||||
joininfo->jinfo_restrictinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.27 2004/05/26 04:41:27 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.28 2004/05/30 23:40:31 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -99,7 +99,7 @@ make_restrictinfo_from_indexclauses(List *indexclauses,
|
||||
if (indexclauses == NIL)
|
||||
return NIL;
|
||||
/* If single indexscan, just return the ANDed clauses */
|
||||
if (length(indexclauses) == 1)
|
||||
if (list_length(indexclauses) == 1)
|
||||
return (List *) linitial(indexclauses);
|
||||
/* Else we need an OR RestrictInfo structure */
|
||||
foreach(orlist, indexclauses)
|
||||
@@ -112,7 +112,7 @@ make_restrictinfo_from_indexclauses(List *indexclauses,
|
||||
andlist = get_actual_clauses(andlist);
|
||||
withoutris = lappend(withoutris, make_ands_explicit(andlist));
|
||||
}
|
||||
return makeList1(make_restrictinfo_internal(make_orclause(withoutris),
|
||||
return list_make1(make_restrictinfo_internal(make_orclause(withoutris),
|
||||
make_orclause(withris),
|
||||
is_pushed_down,
|
||||
valid_everywhere));
|
||||
@@ -139,7 +139,7 @@ make_restrictinfo_internal(Expr *clause, Expr *orclause,
|
||||
* If it's a binary opclause, set up left/right relids info.
|
||||
* In any case set up the total clause relids info.
|
||||
*/
|
||||
if (is_opclause(clause) && length(((OpExpr *) clause)->args) == 2)
|
||||
if (is_opclause(clause) && list_length(((OpExpr *) clause)->args) == 2)
|
||||
{
|
||||
restrictinfo->left_relids = pull_varnos(get_leftop(clause));
|
||||
restrictinfo->right_relids = pull_varnos(get_rightop(clause));
|
||||
@@ -350,7 +350,7 @@ remove_redundant_join_clauses(Query *root, List *restrictinfo_list,
|
||||
else if (CLAUSECOST(rinfo) < CLAUSECOST(prevrinfo))
|
||||
{
|
||||
/* keep this one, drop the previous one */
|
||||
result = lremove(prevrinfo, result);
|
||||
result = list_delete_ptr(result, prevrinfo);
|
||||
result = lappend(result, rinfo);
|
||||
}
|
||||
/* else, drop this one */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/tlist.c,v 1.63 2004/05/26 04:41:27 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/tlist.c,v 1.64 2004/05/30 23:40:31 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -121,7 +121,7 @@ flatten_tlist(List *tlist)
|
||||
List *new_tlist;
|
||||
|
||||
new_tlist = add_to_flat_tlist(NIL, vlist);
|
||||
freeList(vlist);
|
||||
list_free(vlist);
|
||||
return new_tlist;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ flatten_tlist(List *tlist)
|
||||
List *
|
||||
add_to_flat_tlist(List *tlist, List *vars)
|
||||
{
|
||||
int next_resdomno = length(tlist) + 1;
|
||||
int next_resdomno = list_length(tlist) + 1;
|
||||
ListCell *v;
|
||||
|
||||
foreach(v, vars)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/var.c,v 1.57 2004/05/26 04:41:27 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/var.c,v 1.58 2004/05/30 23:40:31 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -543,7 +543,7 @@ flatten_join_alias_vars_mutator(Node *node,
|
||||
|
||||
/* Expand join alias reference */
|
||||
Assert(var->varattno > 0);
|
||||
newvar = (Node *) nth(var->varattno - 1, rte->joinaliasvars);
|
||||
newvar = (Node *) list_nth(rte->joinaliasvars, var->varattno - 1);
|
||||
|
||||
/*
|
||||
* If we are expanding an alias carried down from an upper query,
|
||||
|
||||
Reference in New Issue
Block a user