aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/cluster.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-05-20 23:51:44 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-05-20 23:51:44 +0000
commit44fbe20d620d4f2e39aaa9896de4683e55b0d317 (patch)
tree5717c7d32f5f7ef72318c70c641129176820a2d0 /src/backend/commands/cluster.c
parentc961474c96fd1fedc25896a1de9a98caeedfbe49 (diff)
downloadpostgresql-44fbe20d620d4f2e39aaa9896de4683e55b0d317.tar.gz
postgresql-44fbe20d620d4f2e39aaa9896de4683e55b0d317.zip
Restructure indexscan API (index_beginscan, index_getnext) per
yesterday's proposal to pghackers. Also remove unnecessary parameters to heap_beginscan, heap_rescan. I modified pg_proc.h to reflect the new numbers of parameters for the AM interface routines, but did not force an initdb because nothing actually looks at those fields.
Diffstat (limited to 'src/backend/commands/cluster.c')
-rw-r--r--src/backend/commands/cluster.c44
1 files changed, 16 insertions, 28 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 01a45b0625b..a6215cb23f4 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.79 2002/04/27 21:24:34 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.80 2002/05/20 23:51:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -217,7 +217,7 @@ rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
LocalOldHeap,
LocalOldIndex;
IndexScanDesc ScanDesc;
- RetrieveIndexResult ScanResult;
+ HeapTuple LocalHeapTuple;
/*
* Open the relations I need. Scan through the OldHeap on the OldIndex
@@ -227,36 +227,24 @@ rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
LocalOldHeap = heap_open(OIDOldHeap, AccessExclusiveLock);
LocalOldIndex = index_open(OIDOldIndex);
- ScanDesc = index_beginscan(LocalOldIndex, false, 0, (ScanKey) NULL);
+ ScanDesc = index_beginscan(LocalOldHeap, LocalOldIndex,
+ SnapshotNow, 0, (ScanKey) NULL);
- while ((ScanResult = index_getnext(ScanDesc, ForwardScanDirection)) != NULL)
+ while ((LocalHeapTuple = index_getnext(ScanDesc, ForwardScanDirection)) != NULL)
{
- HeapTupleData LocalHeapTuple;
- Buffer LocalBuffer;
+ /*
+ * We must copy the tuple because heap_insert() will overwrite
+ * the commit-status fields of the tuple it's handed, and the
+ * retrieved tuple will actually be in a disk buffer! Thus,
+ * the source relation would get trashed, which is bad news if
+ * we abort later on. (This was a bug in releases thru 7.0)
+ */
+ HeapTuple copiedTuple = heap_copytuple(LocalHeapTuple);
+
+ heap_insert(LocalNewHeap, copiedTuple);
+ heap_freetuple(copiedTuple);
CHECK_FOR_INTERRUPTS();
-
- LocalHeapTuple.t_self = ScanResult->heap_iptr;
- LocalHeapTuple.t_datamcxt = NULL;
- LocalHeapTuple.t_data = NULL;
- heap_fetch(LocalOldHeap, SnapshotNow, &LocalHeapTuple, &LocalBuffer,
- ScanDesc);
- if (LocalHeapTuple.t_data != NULL)
- {
- /*
- * We must copy the tuple because heap_insert() will overwrite
- * the commit-status fields of the tuple it's handed, and the
- * retrieved tuple will actually be in a disk buffer! Thus,
- * the source relation would get trashed, which is bad news if
- * we abort later on. (This was a bug in releases thru 7.0)
- */
- HeapTuple copiedTuple = heap_copytuple(&LocalHeapTuple);
-
- ReleaseBuffer(LocalBuffer);
- heap_insert(LocalNewHeap, copiedTuple);
- heap_freetuple(copiedTuple);
- }
- pfree(ScanResult);
}
index_endscan(ScanDesc);