aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/heap/heapam.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-11-08 22:10:03 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-11-08 22:10:03 +0000
commit3908473c809d5c24940faebfabdad673f4302178 (patch)
tree6a1989499ee61771c7764afd2b24d12ebd25b8fb /src/backend/access/heap/heapam.c
parentebe0b236909732c75d665c73363bd4ac7a7aa138 (diff)
downloadpostgresql-3908473c809d5c24940faebfabdad673f4302178.tar.gz
postgresql-3908473c809d5c24940faebfabdad673f4302178.zip
Make DROP TABLE rollback-able: postpone physical file delete until commit.
(WAL logging for this is not done yet, however.) Clean up a number of really crufty things that are no longer needed now that DROP behaves nicely. Make temp table mapper do the right things when drop or rename affecting a temp table is rolled back. Also, remove "relation modified while in use" error check, in favor of locking tables at first reference and holding that lock throughout the statement.
Diffstat (limited to 'src/backend/access/heap/heapam.c')
-rw-r--r--src/backend/access/heap/heapam.c36
1 files changed, 10 insertions, 26 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index e796762ef16..5f450f91524 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.92 2000/10/29 18:33:39 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.93 2000/11/08 22:09:54 tgl Exp $
*
*
* INTERFACE ROUTINES
@@ -780,19 +780,13 @@ heap_beginscan(Relation relation,
/* ----------------
* increment relation ref count while scanning relation
- * ----------------
- */
- RelationIncrementReferenceCount(relation);
-
- /* ----------------
- * Acquire AccessShareLock for the duration of the scan
*
- * Note: we could get an SI inval message here and consequently have
- * to rebuild the relcache entry. The refcount increment above
- * ensures that we will rebuild it and not just flush it...
+ * This is just to make really sure the relcache entry won't go away
+ * while the scan has a pointer to it. Caller should be holding the
+ * rel open anyway, so this is redundant in all normal scenarios...
* ----------------
*/
- LockRelation(relation, AccessShareLock);
+ RelationIncrementReferenceCount(relation);
/* XXX someday assert SelfTimeQual if relkind == RELKIND_UNCATALOGED */
if (relation->rd_rel->relkind == RELKIND_UNCATALOGED)
@@ -809,13 +803,11 @@ heap_beginscan(Relation relation,
scan->rs_snapshot = snapshot;
scan->rs_nkeys = (short) nkeys;
+ /*
+ * we do this here instead of in initscan() because heap_rescan
+ * also calls initscan() and we don't want to allocate memory again
+ */
if (nkeys)
-
- /*
- * we do this here instead of in initscan() because heap_rescan
- * also calls initscan() and we don't want to allocate memory
- * again
- */
scan->rs_key = (ScanKey) palloc(sizeof(ScanKeyData) * nkeys);
else
scan->rs_key = NULL;
@@ -841,8 +833,6 @@ heap_rescan(HeapScanDesc scan,
IncrHeapAccessStat(local_rescan);
IncrHeapAccessStat(global_rescan);
- /* Note: set relation level read lock is still set */
-
/* ----------------
* unpin scan buffers
* ----------------
@@ -853,7 +843,7 @@ heap_rescan(HeapScanDesc scan,
* reinitialize scan descriptor
* ----------------
*/
- scan->rs_atend = (bool) scanFromEnd;
+ scan->rs_atend = scanFromEnd;
initscan(scan, scan->rs_rd, scanFromEnd, scan->rs_nkeys, key);
}
@@ -883,12 +873,6 @@ heap_endscan(HeapScanDesc scan)
unpinscan(scan);
/* ----------------
- * Release AccessShareLock acquired by heap_beginscan()
- * ----------------
- */
- UnlockRelation(scan->rs_rd, AccessShareLock);
-
- /* ----------------
* decrement relation reference count and free scan descriptor storage
* ----------------
*/