aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/opclasscmds.c
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2004-05-26 04:41:50 +0000
committerNeil Conway <neilc@samurai.com>2004-05-26 04:41:50 +0000
commitd0b4399d81f39decccb23fa38f772b71b51bf96a (patch)
tree71d3b737f5d93f6c3984412a4910b5810156c5ca /src/backend/commands/opclasscmds.c
parent18d0d105635fbc7e476063e662b449f296953a04 (diff)
downloadpostgresql-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/commands/opclasscmds.c')
-rw-r--r--src/backend/commands/opclasscmds.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index d3551a7349f..db5c2ccabc9 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.24 2003/11/29 19:51:47 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.25 2004/05/26 04:41:11 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -77,7 +77,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
numProcs; /* amsupport value */
List *operators; /* OpClassMember list for operators */
List *procedures; /* OpClassMember list for support procs */
- List *l;
+ ListCell *l;
Relation rel;
HeapTuple tup;
Datum values[Natts_pg_opclass];
@@ -168,7 +168,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
item->number, numOperators)));
if (item->args != NIL)
{
- TypeName *typeName1 = (TypeName *) lfirst(item->args);
+ TypeName *typeName1 = (TypeName *) linitial(item->args);
TypeName *typeName2 = (TypeName *) lsecond(item->args);
operOid = LookupOperNameTypeNames(item->name,
@@ -506,7 +506,7 @@ assignProcSubtype(Oid amoid, Oid typeoid, Oid procOid)
static void
addClassMember(List **list, OpClassMember *member, bool isProc)
{
- List *l;
+ ListCell *l;
foreach(l, *list)
{
@@ -540,7 +540,7 @@ storeOperators(Oid opclassoid, List *operators)
Datum values[Natts_pg_amop];
char nulls[Natts_pg_amop];
HeapTuple tup;
- List *l;
+ ListCell *l;
int i;
rel = heap_openr(AccessMethodOperatorRelationName, RowExclusiveLock);
@@ -584,7 +584,7 @@ storeProcedures(Oid opclassoid, List *procedures)
Datum values[Natts_pg_amproc];
char nulls[Natts_pg_amproc];
HeapTuple tup;
- List *l;
+ ListCell *l;
int i;
rel = heap_openr(AccessMethodProcedureRelationName, RowExclusiveLock);