This can result in buffers failing to be properly flushed at
checkpoint time, leading to data loss.
Report, diagnosis, and patch by Jeff Davis.
    FakeRelCacheEntry fakeentry;
    Relation    rel;
 
+   Assert(InRecovery);
+
    /* Allocate the Relation struct and all related space in one block. */
    fakeentry = palloc0(sizeof(FakeRelCacheEntryData));
    rel = (Relation) fakeentry;
    /* We will never be working with temp rels during recovery */
    rel->rd_backend = InvalidBackendId;
 
+   /* It must be a permanent table if we're in recovery. */
+   rel->rd_rel->relpersistence = RELPERSISTENCE_PERMANENT;
+
    /* We don't know the name of the relation; use relfilenode instead */
    sprintf(RelationGetRelationName(rel), "%u", rnode.relNode);
 
 
 
    SMgrRelation smgr = smgropen(rnode, InvalidBackendId);
 
+   Assert(InRecovery);
+
    return ReadBuffer_common(smgr, RELPERSISTENCE_PERMANENT, forkNum, blockNum,
                             mode, strategy, &hit);
 }