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/clausesel.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/clausesel.c')
-rw-r--r-- | src/backend/optimizer/path/clausesel.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/backend/optimizer/path/clausesel.c b/src/backend/optimizer/path/clausesel.c index 96ce94c8fcb..c8b54bf223a 100644 --- a/src/backend/optimizer/path/clausesel.c +++ b/src/backend/optimizer/path/clausesel.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.65 2004/05/10 22:44:45 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.66 2004/05/26 04:41:21 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -98,16 +98,16 @@ clauselist_selectivity(Query *root, { Selectivity s1 = 1.0; RangeQueryClause *rqlist = NULL; - List *clist; + ListCell *l; /* * Initial scan over clauses. Anything that doesn't look like a * potential rangequery clause gets multiplied into s1 and forgotten. * Anything that does gets inserted into an rqlist entry. */ - foreach(clist, clauses) + foreach(l, clauses) { - Node *clause = (Node *) lfirst(clist); + Node *clause = (Node *) lfirst(l); RestrictInfo *rinfo; Selectivity s2; @@ -143,7 +143,7 @@ clauselist_selectivity(Query *root, (is_pseudo_constant_clause_relids(lsecond(expr->args), rinfo->right_relids) || (varonleft = false, - is_pseudo_constant_clause_relids(lfirst(expr->args), + is_pseudo_constant_clause_relids(linitial(expr->args), rinfo->left_relids))); } else @@ -151,7 +151,7 @@ clauselist_selectivity(Query *root, ok = (NumRelids(clause) == 1) && (is_pseudo_constant_clause(lsecond(expr->args)) || (varonleft = false, - is_pseudo_constant_clause(lfirst(expr->args)))); + is_pseudo_constant_clause(linitial(expr->args)))); } if (ok) @@ -521,7 +521,7 @@ clause_selectivity(Query *root, * * XXX is this too conservative? */ - List *arg; + ListCell *arg; s1 = 0.0; foreach(arg, ((BoolExpr *) clause)->args) |