@@ -1104,7 +1104,7 @@ ZeroAndLockBuffer(Buffer buffer, ReadBufferMode mode, bool already_valid)
1104
1104
static pg_attribute_always_inline Buffer
1105
1105
PinBufferForBlock (Relation rel ,
1106
1106
SMgrRelation smgr ,
1107
- char smgr_persistence ,
1107
+ char persistence ,
1108
1108
ForkNumber forkNum ,
1109
1109
BlockNumber blockNum ,
1110
1110
BufferAccessStrategy strategy ,
@@ -1113,14 +1113,13 @@ PinBufferForBlock(Relation rel,
1113
1113
BufferDesc * bufHdr ;
1114
1114
IOContext io_context ;
1115
1115
IOObject io_object ;
1116
- char persistence ;
1117
1116
1118
1117
Assert (blockNum != P_NEW );
1119
1118
1120
- if ( rel )
1121
- persistence = rel -> rd_rel -> relpersistence ;
1122
- else
1123
- persistence = smgr_persistence ;
1119
+ /* Persistence should be set before */
1120
+ Assert (( persistence == RELPERSISTENCE_TEMP ||
1121
+ persistence == RELPERSISTENCE_PERMANENT ||
1122
+ persistence == RELPERSISTENCE_UNLOGGED )) ;
1124
1123
1125
1124
if (persistence == RELPERSISTENCE_TEMP )
1126
1125
{
@@ -1195,6 +1194,7 @@ ReadBuffer_common(Relation rel, SMgrRelation smgr, char smgr_persistence,
1195
1194
ReadBuffersOperation operation ;
1196
1195
Buffer buffer ;
1197
1196
int flags ;
1197
+ char persistence ;
1198
1198
1199
1199
/*
1200
1200
* Backward compatibility path, most code should use ExtendBufferedRel()
@@ -1216,12 +1216,17 @@ ReadBuffer_common(Relation rel, SMgrRelation smgr, char smgr_persistence,
1216
1216
return ExtendBufferedRel (BMR_REL (rel ), forkNum , strategy , flags );
1217
1217
}
1218
1218
1219
+ if (rel )
1220
+ persistence = rel -> rd_rel -> relpersistence ;
1221
+ else
1222
+ persistence = smgr_persistence ;
1223
+
1219
1224
if (unlikely (mode == RBM_ZERO_AND_CLEANUP_LOCK ||
1220
1225
mode == RBM_ZERO_AND_LOCK ))
1221
1226
{
1222
1227
bool found ;
1223
1228
1224
- buffer = PinBufferForBlock (rel , smgr , smgr_persistence ,
1229
+ buffer = PinBufferForBlock (rel , smgr , persistence ,
1225
1230
forkNum , blockNum , strategy , & found );
1226
1231
ZeroAndLockBuffer (buffer , mode , found );
1227
1232
return buffer ;
@@ -1233,7 +1238,7 @@ ReadBuffer_common(Relation rel, SMgrRelation smgr, char smgr_persistence,
1233
1238
flags = 0 ;
1234
1239
operation .smgr = smgr ;
1235
1240
operation .rel = rel ;
1236
- operation .smgr_persistence = smgr_persistence ;
1241
+ operation .persistence = persistence ;
1237
1242
operation .forknum = forkNum ;
1238
1243
operation .strategy = strategy ;
1239
1244
if (StartReadBuffer (& operation ,
@@ -1264,7 +1269,7 @@ StartReadBuffersImpl(ReadBuffersOperation *operation,
1264
1269
1265
1270
buffers [i ] = PinBufferForBlock (operation -> rel ,
1266
1271
operation -> smgr ,
1267
- operation -> smgr_persistence ,
1272
+ operation -> persistence ,
1268
1273
operation -> forknum ,
1269
1274
blockNum + i ,
1270
1275
operation -> strategy ,
@@ -1410,10 +1415,8 @@ WaitReadBuffers(ReadBuffersOperation *operation)
1410
1415
buffers = & operation -> buffers [0 ];
1411
1416
blocknum = operation -> blocknum ;
1412
1417
forknum = operation -> forknum ;
1418
+ persistence = operation -> persistence ;
1413
1419
1414
- persistence = operation -> rel
1415
- ? operation -> rel -> rd_rel -> relpersistence
1416
- : RELPERSISTENCE_PERMANENT ;
1417
1420
if (persistence == RELPERSISTENCE_TEMP )
1418
1421
{
1419
1422
io_context = IOCONTEXT_NORMAL ;
0 commit comments