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/parser/parse_coerce.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/parser/parse_coerce.c')
-rw-r--r-- | src/backend/parser/parse_coerce.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index c7a8c3c83bb..ba3210946ab 100644 --- a/src/backend/parser/parse_coerce.c +++ b/src/backend/parser/parse_coerce.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.115 2004/05/10 22:44:46 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.116 2004/05/26 04:41:30 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -546,7 +546,7 @@ coerce_record_to_complex(ParseState *pstate, Node *node, List *args = NIL; List *newargs; int i; - List *arg; + ListCell *arg; if (node && IsA(node, RowExpr)) { @@ -720,14 +720,15 @@ select_common_type(List *typeids, const char *context) { Oid ptype; CATEGORY pcategory; - List *l; + ListCell *type_item; Assert(typeids != NIL); - ptype = getBaseType(lfirsto(typeids)); + ptype = getBaseType(linitial_oid(typeids)); pcategory = TypeCategory(ptype); - foreach(l, lnext(typeids)) + + for_each_cell(type_item, lnext(list_head(typeids))) { - Oid ntype = getBaseType(lfirsto(l)); + Oid ntype = getBaseType(lfirsto(type_item)); /* move on to next one if no new information... */ if ((ntype != InvalidOid) && (ntype != UNKNOWNOID) && (ntype != ptype)) @@ -746,7 +747,6 @@ select_common_type(List *typeids, const char *context) */ ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - /* * translator: first %s is name of a SQL construct, eg * CASE |