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/path/orindxpath.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/path/orindxpath.c')
-rw-r--r-- | src/backend/optimizer/path/orindxpath.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/backend/optimizer/path/orindxpath.c b/src/backend/optimizer/path/orindxpath.c index 9722b69965d..cc160e7a46e 100644 --- a/src/backend/optimizer/path/orindxpath.c +++ b/src/backend/optimizer/path/orindxpath.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.57 2004/01/05 23:39:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.58 2004/05/26 04:41:22 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -100,7 +100,7 @@ create_or_index_quals(Query *root, RelOptInfo *rel) RestrictInfo *or_rinfo; Selectivity or_selec, orig_selec; - List *i; + ListCell *i; /* * We use the best_or_subclause_indexes() machinery to locate the @@ -111,7 +111,7 @@ create_or_index_quals(Query *root, RelOptInfo *rel) foreach(i, rel->joininfo) { JoinInfo *joininfo = (JoinInfo *) lfirst(i); - List *j; + ListCell *j; foreach(j, joininfo->jinfo_restrictinfo) { @@ -150,7 +150,7 @@ create_or_index_quals(Query *root, RelOptInfo *rel) newrinfos = make_restrictinfo_from_indexclauses(bestpath->indexclauses, true, true); Assert(length(newrinfos) == 1); - or_rinfo = (RestrictInfo *) lfirst(newrinfos); + or_rinfo = (RestrictInfo *) linitial(newrinfos); rel->baserestrictinfo = nconc(rel->baserestrictinfo, newrinfos); /* @@ -190,15 +190,15 @@ create_or_index_quals(Query *root, RelOptInfo *rel) void create_or_index_paths(Query *root, RelOptInfo *rel) { - List *i; + ListCell *l; /* * Check each restriction clause to see if it is an OR clause, and if so, * try to make a path using it. */ - foreach(i, rel->baserestrictinfo) + foreach(l, rel->baserestrictinfo) { - RestrictInfo *rinfo = (RestrictInfo *) lfirst(i); + RestrictInfo *rinfo = (RestrictInfo *) lfirst(l); if (restriction_is_or_clause(rinfo)) { @@ -248,7 +248,7 @@ best_or_subclause_indexes(Query *root, FastList quals; Cost path_startup_cost; Cost path_total_cost; - List *slist; + ListCell *slist; IndexPath *pathnode; FastListInit(&infos); @@ -283,7 +283,7 @@ best_or_subclause_indexes(Query *root, * * Total cost is sum of the per-scan costs. */ - if (slist == subclauses) /* first scan? */ + if (slist == list_head(subclauses)) /* first scan? */ path_startup_cost = best_startup_cost; path_total_cost += best_total_cost; } @@ -351,7 +351,7 @@ best_or_subclause_index(Query *root, Cost *retTotalCost) /* return value */ { bool found = false; - List *ilist; + ListCell *ilist; foreach(ilist, rel->indexlist) { |