summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian1998-06-13 20:22:54 +0000
committerBruce Momjian1998-06-13 20:22:54 +0000
commit1e88d82462962df4f9082e1f4f0b8268d10e8573 (patch)
tree7c89777d34549bd3790155d4d0e73d6bcf6e5ce7
parentd3d541996b52f6170c2613129e8b8be2b0411943 (diff)
Fix problem with table drop after rollback of transaction, no flush
of index tuples. Thanks to Vadim for fix.
-rw-r--r--src/backend/catalog/heap.c12
-rw-r--r--src/backend/catalog/index.c8
2 files changed, 9 insertions, 11 deletions
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index c9bfa2e437a..acc9a8a7353 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -7,12 +7,12 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.48 1998/04/27 04:04:47 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.49 1998/06/13 20:22:53 momjian Exp $
*
* INTERFACE ROUTINES
* heap_create() - Create an uncataloged heap relation
* heap_create_with_catalog() - Create a cataloged relation
- * heap_destroy_with_catalog() - Removes named relation from catalogs
+ * heap_destroy_with_catalog() - Removes named relation from catalogs
*
* NOTES
* this code taken from access/heap/create.c, which contains
@@ -1290,18 +1290,14 @@ heap_destroy_with_catalog(char *relname)
* ----------------
*/
if (rdesc->rd_rel->relhasindex)
- {
RelationRemoveIndexes(rdesc);
- }
/* ----------------
* remove rules if necessary
* ----------------
*/
if (rdesc->rd_rules != NULL)
- {
RelationRemoveRules(rid);
- }
/* triggers */
if (rdesc->rd_rel->reltriggers > 0)
@@ -1347,9 +1343,8 @@ heap_destroy_with_catalog(char *relname)
* ----------------
*/
if (!(rdesc->rd_istemp) || !(rdesc->rd_tmpunlinked))
- {
smgrunlink(DEFAULT_SMGR, rdesc);
- }
+
rdesc->rd_tmpunlinked = TRUE;
RelationUnsetLockForWrite(rdesc);
@@ -1375,6 +1370,7 @@ heap_destroy(Relation rdesc)
rdesc->rd_tmpunlinked = TRUE;
heap_close(rdesc);
RemoveFromTempRelList(rdesc);
+ RelationForgetRelation(rdesc->rd_id);
}
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index aca9fdf6ec2..69a71858c16 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.41 1998/05/09 23:42:59 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.42 1998/06/13 20:22:54 momjian Exp $
*
*
* INTERFACE ROUTINES
@@ -1270,7 +1270,6 @@ index_destroy(Oid indexId)
while (tuple = heap_getnext(scan, 0, (Buffer *) NULL),
HeapTupleIsValid(tuple))
{
-
heap_delete(catalogRelation, &tuple->t_ctid);
}
heap_endscan(scan);
@@ -1296,12 +1295,15 @@ index_destroy(Oid indexId)
heap_close(catalogRelation);
/*
- * physically remove the file
+ * flush cache and physically remove the file
*/
+ ReleaseRelationBuffers(indexRelation);
+
if (FileNameUnlink(relpath(indexRelation->rd_rel->relname.data)) < 0)
elog(ERROR, "amdestroyr: unlink: %m");
index_close(indexRelation);
+ RelationForgetRelation(indexRelation->rd_id);
}
/* ----------------------------------------------------------------