@@ -239,8 +239,10 @@ visibilitymap_pin_ok(BlockNumber heapBlk, Buffer vmbuf)
239
239
* You must pass a buffer containing the correct map page to this function.
240
240
* Call visibilitymap_pin first to pin the right one. This function doesn't do
241
241
* any I/O.
242
+ *
243
+ * Returns the state of the page's VM bits before setting flags.
242
244
*/
243
- void
245
+ uint8
244
246
visibilitymap_set (Relation rel , BlockNumber heapBlk , Buffer heapBuf ,
245
247
XLogRecPtr recptr , Buffer vmBuf , TransactionId cutoff_xid ,
246
248
uint8 flags )
@@ -250,6 +252,7 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
250
252
uint8 mapOffset = HEAPBLK_TO_OFFSET (heapBlk );
251
253
Page page ;
252
254
uint8 * map ;
255
+ uint8 status ;
253
256
254
257
#ifdef TRACE_VISIBILITYMAP
255
258
elog (DEBUG1 , "vm_set %s %d" , RelationGetRelationName (rel ), heapBlk );
@@ -274,7 +277,8 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
274
277
map = (uint8 * ) PageGetContents (page );
275
278
LockBuffer (vmBuf , BUFFER_LOCK_EXCLUSIVE );
276
279
277
- if (flags != (map [mapByte ] >> mapOffset & VISIBILITYMAP_VALID_BITS ))
280
+ status = (map [mapByte ] >> mapOffset ) & VISIBILITYMAP_VALID_BITS ;
281
+ if (flags != status )
278
282
{
279
283
START_CRIT_SECTION ();
280
284
@@ -311,6 +315,7 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
311
315
}
312
316
313
317
LockBuffer (vmBuf , BUFFER_LOCK_UNLOCK );
318
+ return status ;
314
319
}
315
320
316
321
/*
0 commit comments