Commit 791e9973 authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

heap_destroy () releases dirty buffers of a relation to be

destroyed.
parent cbac9867
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.10 1997/01/01 06:01:16 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.11 1997/01/14 05:38:23 vadim Exp $
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
* heap_creatr() - Create an uncataloged heap relation * heap_creatr() - Create an uncataloged heap relation
...@@ -1233,6 +1233,8 @@ heap_destroy(char *relname) ...@@ -1233,6 +1233,8 @@ heap_destroy(char *relname)
rdesc = heap_openr(relname); rdesc = heap_openr(relname);
if (rdesc == NULL) if (rdesc == NULL)
elog(WARN,"Relation %s Does Not Exist!", relname); elog(WARN,"Relation %s Does Not Exist!", relname);
RelationSetLockForWrite(rdesc);
/* ---------------- /* ----------------
* prevent deletion of system relations * prevent deletion of system relations
...@@ -1285,6 +1287,11 @@ heap_destroy(char *relname) ...@@ -1285,6 +1287,11 @@ heap_destroy(char *relname)
*/ */
DeletePgRelationTuple(rdesc); DeletePgRelationTuple(rdesc);
/*
* release dirty buffers of this relation
*/
ReleaseRelationBuffers (rdesc);
/* ---------------- /* ----------------
* flush the relation from the relcache * flush the relation from the relcache
* ---------------- * ----------------
...@@ -1299,6 +1306,9 @@ heap_destroy(char *relname) ...@@ -1299,6 +1306,9 @@ heap_destroy(char *relname)
if(rdesc->rd_istemp) { if(rdesc->rd_istemp) {
rdesc->rd_tmpunlinked = TRUE; rdesc->rd_tmpunlinked = TRUE;
} }
RelationUnsetLockForWrite(rdesc);
heap_close(rdesc); heap_close(rdesc);
} }
...@@ -1311,7 +1321,7 @@ heap_destroy(char *relname) ...@@ -1311,7 +1321,7 @@ heap_destroy(char *relname)
void void
heap_destroyr(Relation rdesc) heap_destroyr(Relation rdesc)
{ {
ReleaseTmpRelBuffers(rdesc); ReleaseRelationBuffers(rdesc);
(void) smgrunlink(rdesc->rd_rel->relsmgr, rdesc); (void) smgrunlink(rdesc->rd_rel->relsmgr, rdesc);
if(rdesc->rd_istemp) { if(rdesc->rd_istemp) {
rdesc->rd_tmpunlinked = TRUE; rdesc->rd_tmpunlinked = TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment