aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/cluster.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/cluster.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/cluster.c')
-rw-r--r--src/backend/commands/cluster.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 168ae749fa0..d9c4397176b 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.123 2004/05/08 00:34:49 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.124 2004/05/26 04:41:10 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -103,7 +103,7 @@ cluster(ClusterStmt *stmt)
if (stmt->indexname == NULL)
{
- List *index;
+ ListCell *index;
/* We need to find the index that has indisclustered set. */
foreach(index, RelationGetIndexList(rel))
@@ -111,7 +111,7 @@ cluster(ClusterStmt *stmt)
HeapTuple idxtuple;
Form_pg_index indexForm;
- indexOid = lfirsto(index);
+ indexOid = lfirst_oid(index);
idxtuple = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(indexOid),
0, 0, 0);
@@ -165,8 +165,8 @@ cluster(ClusterStmt *stmt)
* tables that have some index with indisclustered set.
*/
MemoryContext cluster_context;
- List *rv,
- *rvs;
+ List *rvs;
+ ListCell *rv;
/*
* We cannot run this form of CLUSTER inside a user transaction
@@ -408,7 +408,7 @@ mark_index_clustered(Relation rel, Oid indexOid)
HeapTuple indexTuple;
Form_pg_index indexForm;
Relation pg_index;
- List *index;
+ ListCell *index;
/*
* If the index is already marked clustered, no need to do anything.
@@ -438,7 +438,7 @@ mark_index_clustered(Relation rel, Oid indexOid)
foreach(index, RelationGetIndexList(rel))
{
- Oid thisIndexOid = lfirsto(index);
+ Oid thisIndexOid = lfirst_oid(index);
indexTuple = SearchSysCacheCopy(INDEXRELID,
ObjectIdGetDatum(thisIndexOid),