Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1e88d82

Browse files
committed
Fix problem with table drop after rollback of transaction, no flush
of index tuples. Thanks to Vadim for fix.
1 parent d3d5419 commit 1e88d82

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/backend/catalog/heap.c

+4-8
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.48 1998/04/27 04:04:47 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.49 1998/06/13 20:22:53 momjian Exp $
1111
*
1212
* INTERFACE ROUTINES
1313
* heap_create() - Create an uncataloged heap relation
1414
* heap_create_with_catalog() - Create a cataloged relation
15-
* heap_destroy_with_catalog() - Removes named relation from catalogs
15+
* heap_destroy_with_catalog() - Removes named relation from catalogs
1616
*
1717
* NOTES
1818
* this code taken from access/heap/create.c, which contains
@@ -1290,18 +1290,14 @@ heap_destroy_with_catalog(char *relname)
12901290
* ----------------
12911291
*/
12921292
if (rdesc->rd_rel->relhasindex)
1293-
{
12941293
RelationRemoveIndexes(rdesc);
1295-
}
12961294

12971295
/* ----------------
12981296
* remove rules if necessary
12991297
* ----------------
13001298
*/
13011299
if (rdesc->rd_rules != NULL)
1302-
{
13031300
RelationRemoveRules(rid);
1304-
}
13051301

13061302
/* triggers */
13071303
if (rdesc->rd_rel->reltriggers > 0)
@@ -1347,9 +1343,8 @@ heap_destroy_with_catalog(char *relname)
13471343
* ----------------
13481344
*/
13491345
if (!(rdesc->rd_istemp) || !(rdesc->rd_tmpunlinked))
1350-
{
13511346
smgrunlink(DEFAULT_SMGR, rdesc);
1352-
}
1347+
13531348
rdesc->rd_tmpunlinked = TRUE;
13541349

13551350
RelationUnsetLockForWrite(rdesc);
@@ -1375,6 +1370,7 @@ heap_destroy(Relation rdesc)
13751370
rdesc->rd_tmpunlinked = TRUE;
13761371
heap_close(rdesc);
13771372
RemoveFromTempRelList(rdesc);
1373+
RelationForgetRelation(rdesc->rd_id);
13781374
}
13791375

13801376

src/backend/catalog/index.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.41 1998/05/09 23:42:59 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.42 1998/06/13 20:22:54 momjian Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -1270,7 +1270,6 @@ index_destroy(Oid indexId)
12701270
while (tuple = heap_getnext(scan, 0, (Buffer *) NULL),
12711271
HeapTupleIsValid(tuple))
12721272
{
1273-
12741273
heap_delete(catalogRelation, &tuple->t_ctid);
12751274
}
12761275
heap_endscan(scan);
@@ -1296,12 +1295,15 @@ index_destroy(Oid indexId)
12961295
heap_close(catalogRelation);
12971296

12981297
/*
1299-
* physically remove the file
1298+
* flush cache and physically remove the file
13001299
*/
1300+
ReleaseRelationBuffers(indexRelation);
1301+
13011302
if (FileNameUnlink(relpath(indexRelation->rd_rel->relname.data)) < 0)
13021303
elog(ERROR, "amdestroyr: unlink: %m");
13031304

13041305
index_close(indexRelation);
1306+
RelationForgetRelation(indexRelation->rd_id);
13051307
}
13061308

13071309
/* ----------------------------------------------------------------

0 commit comments

Comments
 (0)