Remove smgrdounlink() in smgr.c from the code tree
authorMichael Paquier <[email protected]>
Sun, 10 May 2020 01:58:54 +0000 (10:58 +0900)
committerMichael Paquier <[email protected]>
Sun, 10 May 2020 01:58:54 +0000 (10:58 +0900)
The last caller of this routine was removed in b416691, and as a wise
man said one day, dead code tends to silently break.

Per discussion between Fujii Masao, Peter Geoghegan, Vignesh C and me.

Reported-by: Peter Geoghegan
Discussion: https://postgr.es/m/CAH2-Wz=sg5H8-vG4d5UmAofdcRMpeTDt2K-NUWp4GSfhenRGAQ@mail.gmail.com

src/backend/storage/smgr/smgr.c
src/include/storage/smgr.h

index b053a4dc761e61ee99a91035e560d0ea83aa3920..e6fa2148fc7b35eab754f33afe540ecbb94b6e8f 100644 (file)
@@ -335,59 +335,6 @@ smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo)
        smgrsw[reln->smgr_which].smgr_create(reln, forknum, isRedo);
 }
 
-/*
- *     smgrdounlink() -- Immediately unlink all forks of a relation.
- *
- *             All forks of the relation are removed from the store.  This should
- *             not be used during transactional operations, since it can't be undone.
- *
- *             If isRedo is true, it is okay for the underlying file(s) to be gone
- *             already.
- */
-void
-smgrdounlink(SMgrRelation reln, bool isRedo)
-{
-       RelFileNodeBackend rnode = reln->smgr_rnode;
-       int                     which = reln->smgr_which;
-       ForkNumber      forknum;
-
-       /* Close the forks at smgr level */
-       for (forknum = 0; forknum <= MAX_FORKNUM; forknum++)
-               smgrsw[which].smgr_close(reln, forknum);
-
-       /*
-        * Get rid of any remaining buffers for the relation.  bufmgr will just
-        * drop them without bothering to write the contents.
-        */
-       DropRelFileNodesAllBuffers(&rnode, 1);
-
-       /*
-        * It'd be nice to tell the stats collector to forget it immediately, too.
-        * But we can't because we don't know the OID (and in cases involving
-        * relfilenode swaps, it's not always clear which table OID to forget,
-        * anyway).
-        */
-
-       /*
-        * Send a shared-inval message to force other backends to close any
-        * dangling smgr references they may have for this rel.  We should do this
-        * before starting the actual unlinking, in case we fail partway through
-        * that step.  Note that the sinval message will eventually come back to
-        * this backend, too, and thereby provide a backstop that we closed our
-        * own smgr rel.
-        */
-       CacheInvalidateSmgr(rnode);
-
-       /*
-        * Delete the physical file(s).
-        *
-        * Note: smgr_unlink must treat deletion failure as a WARNING, not an
-        * ERROR, because we've already decided to commit or abort the current
-        * xact.
-        */
-       smgrsw[which].smgr_unlink(rnode, InvalidForkNumber, isRedo);
-}
-
 /*
  *     smgrdosyncall() -- Immediately sync all forks of all given relations
  *
@@ -432,9 +379,6 @@ smgrdosyncall(SMgrRelation *rels, int nrels)
  *
  *             If isRedo is true, it is okay for the underlying file(s) to be gone
  *             already.
- *
- *             This is equivalent to calling smgrdounlink for each relation, but it's
- *             significantly quicker so should be preferred when possible.
  */
 void
 smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
index bb8428f27f609073c8da0b2ed6aeca750236ca94..656665959319ee98dc3a6d9e35195f48ef6817c1 100644 (file)
@@ -88,7 +88,6 @@ extern void smgrclose(SMgrRelation reln);
 extern void smgrcloseall(void);
 extern void smgrclosenode(RelFileNodeBackend rnode);
 extern void smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo);
-extern void smgrdounlink(SMgrRelation reln, bool isRedo);
 extern void smgrdosyncall(SMgrRelation *rels, int nrels);
 extern void smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo);
 extern void smgrextend(SMgrRelation reln, ForkNumber forknum,