Remove "smgr_persistence == 0" dead code.
authorNoah Misch <[email protected]>
Sat, 20 Jul 2024 11:22:12 +0000 (04:22 -0700)
committerNoah Misch <[email protected]>
Sat, 20 Jul 2024 11:22:12 +0000 (04:22 -0700)
Reaching that code would have required multiple processes performing
relation extension during recovery, which does not happen.  That caller
has the persistence available, so pass it.  This was dead code as soon
as commit 210622c60e1a9db2e2730140b8106ab57d259d15 added it.

Discussion: https://postgr.es/m/CAN55FZ0JKL6vk1xQp6rfOXiNFV1u1H0tJDPPGHWoiO3ea2Wc=A@mail.gmail.com

src/backend/storage/buffer/bufmgr.c
src/include/storage/bufmgr.h

index 6181673095572a324c7354d672755edca796e7b9..db3eb2cce1ec84f8350a6612cbb45746f1088ef0 100644 (file)
@@ -1002,7 +1002,7 @@ ExtendBufferedRelTo(BufferManagerRelation bmr,
    if (buffer == InvalidBuffer)
    {
        Assert(extended_by == 0);
-       buffer = ReadBuffer_common(bmr.rel, bmr.smgr, 0,
+       buffer = ReadBuffer_common(bmr.rel, bmr.smgr, bmr.relpersistence,
                                   fork, extend_to - 1, mode, strategy);
    }
 
@@ -1117,16 +1117,8 @@ PinBufferForBlock(Relation rel,
 
    Assert(blockNum != P_NEW);
 
-   /*
-    * If there is no Relation it usually implies recovery and thus permanent,
-    * but we take an argument because CreateAndCopyRelationData can reach us
-    * with only an SMgrRelation for an unlogged relation that we don't want
-    * to flag with BM_PERMANENT.
-    */
    if (rel)
        persistence = rel->rd_rel->relpersistence;
-   else if (smgr_persistence == 0)
-       persistence = RELPERSISTENCE_PERMANENT;
    else
        persistence = smgr_persistence;
 
index a1e71013d328f2afd54f1fb2085b436604a32ce7..bc26a4536ff07d700bfe17ebb974e8e2c8918aac 100644 (file)
@@ -114,14 +114,10 @@ typedef struct BufferManagerRelation
 
 struct ReadBuffersOperation
 {
-   /*
-    * The following members should be set by the caller.  If only smgr is
-    * provided without rel, then smgr_persistence can be set to override the
-    * default assumption of RELPERSISTENCE_PERMANENT.
-    */
-   Relation    rel;
+   /* The following members should be set by the caller. */
+   Relation    rel;            /* optional */
    struct SMgrRelationData *smgr;
-   char        smgr_persistence;
+   char        smgr_persistence;   /* optional if rel != NULL */
    ForkNumber  forknum;
    BufferAccessStrategy strategy;