diff options
author | Neil Conway <neilc@samurai.com> | 2004-05-26 04:41:50 +0000 |
---|---|---|
committer | Neil Conway <neilc@samurai.com> | 2004-05-26 04:41:50 +0000 |
commit | d0b4399d81f39decccb23fa38f772b71b51bf96a (patch) | |
tree | 71d3b737f5d93f6c3984412a4910b5810156c5ca /src/backend/optimizer/util/restrictinfo.c | |
parent | 18d0d105635fbc7e476063e662b449f296953a04 (diff) | |
download | postgresql-d0b4399d81f39decccb23fa38f772b71b51bf96a.tar.gz postgresql-d0b4399d81f39decccb23fa38f772b71b51bf96a.zip |
Reimplement the linked list data structure used throughout the backend.
In the past, we used a 'Lispy' linked list implementation: a "list" was
merely a pointer to the head node of the list. The problem with that
design is that it makes lappend() and length() linear time. This patch
fixes that problem (and others) by maintaining a count of the list
length and a pointer to the tail node along with each head node pointer.
A "list" is now a pointer to a structure containing some meta-data
about the list; the head and tail pointers in that structure refer
to ListCell structures that maintain the actual linked list of nodes.
The function names of the list API have also been changed to, I hope,
be more logically consistent. By default, the old function names are
still available; they will be disabled-by-default once the rest of
the tree has been updated to use the new API names.
Diffstat (limited to 'src/backend/optimizer/util/restrictinfo.c')
-rw-r--r-- | src/backend/optimizer/util/restrictinfo.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/backend/optimizer/util/restrictinfo.c b/src/backend/optimizer/util/restrictinfo.c index ddf965fdf2b..1cb446e44fa 100644 --- a/src/backend/optimizer/util/restrictinfo.c +++ b/src/backend/optimizer/util/restrictinfo.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.26 2004/02/27 21:48:04 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.27 2004/05/26 04:41:27 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -93,14 +93,14 @@ make_restrictinfo_from_indexclauses(List *indexclauses, { List *withris = NIL; List *withoutris = NIL; - List *orlist; + ListCell *orlist; /* Empty list probably can't happen, but here's what to do */ if (indexclauses == NIL) return NIL; /* If single indexscan, just return the ANDed clauses */ - if (lnext(indexclauses) == NIL) - return (List *) lfirst(indexclauses); + if (length(indexclauses) == 1) + return (List *) linitial(indexclauses); /* Else we need an OR RestrictInfo structure */ foreach(orlist, indexclauses) { @@ -206,7 +206,7 @@ make_sub_restrictinfos(Expr *clause, bool is_pushed_down, if (or_clause((Node *) clause)) { List *orlist = NIL; - List *temp; + ListCell *temp; foreach(temp, ((BoolExpr *) clause)->args) orlist = lappend(orlist, @@ -218,7 +218,7 @@ make_sub_restrictinfos(Expr *clause, bool is_pushed_down, else if (and_clause((Node *) clause)) { List *andlist = NIL; - List *temp; + ListCell *temp; foreach(temp, ((BoolExpr *) clause)->args) andlist = lappend(andlist, @@ -257,7 +257,7 @@ List * get_actual_clauses(List *restrictinfo_list) { List *result = NIL; - List *temp; + ListCell *temp; foreach(temp, restrictinfo_list) { @@ -280,7 +280,7 @@ void get_actual_join_clauses(List *restrictinfo_list, List **joinquals, List **otherquals) { - List *temp; + ListCell *temp; *joinquals = NIL; *otherquals = NIL; @@ -317,7 +317,7 @@ remove_redundant_join_clauses(Query *root, List *restrictinfo_list, JoinType jointype) { List *result = NIL; - List *item; + ListCell *item; QualCost cost; /* @@ -380,7 +380,7 @@ select_nonredundant_join_clauses(Query *root, JoinType jointype) { List *result = NIL; - List *item; + ListCell *item; foreach(item, restrictinfo_list) { @@ -431,7 +431,7 @@ join_clause_is_redundant(Query *root, List *reference_list, JoinType jointype) { - List *refitem; + ListCell *refitem; /* always consider exact duplicates redundant */ foreach(refitem, reference_list) |