Make visibilitymap_set() return previous state of vmbits
It can be useful to know the state of a relation page's VM bits before visibilitymap_set(). visibilitymap_set() has the old value on hand, so returning it is simple. This commit does not use visibilitymap_set()'s new return value. Author: Melanie Plageman Reviewed-by: Masahiko Sawada, Andres Freund, Nitin Jadhav, Bilal Yavuz Discussion: https://postgr.es/m/flat/CAAKRu_ZQe26xdvAqo4weHLR%3DivQ8J4xrSfDDD8uXnh-O-6P6Lg%40mail.gmail.com#6d8d2b4219394f774889509bf3bdc13d, https://postgr.es/m/ctdjzroezaxmiyah3gwbwm67defsrwj2b5fpfs4ku6msfpxeia%40mwjyqlhwr2wu
This commit is contained in:
parent
f020baa066
commit
4b565a198b
@ -239,8 +239,10 @@ visibilitymap_pin_ok(BlockNumber heapBlk, Buffer vmbuf)
|
|||||||
* You must pass a buffer containing the correct map page to this function.
|
* You must pass a buffer containing the correct map page to this function.
|
||||||
* Call visibilitymap_pin first to pin the right one. This function doesn't do
|
* Call visibilitymap_pin first to pin the right one. This function doesn't do
|
||||||
* any I/O.
|
* any I/O.
|
||||||
|
*
|
||||||
|
* Returns the state of the page's VM bits before setting flags.
|
||||||
*/
|
*/
|
||||||
void
|
uint8
|
||||||
visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
|
visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
|
||||||
XLogRecPtr recptr, Buffer vmBuf, TransactionId cutoff_xid,
|
XLogRecPtr recptr, Buffer vmBuf, TransactionId cutoff_xid,
|
||||||
uint8 flags)
|
uint8 flags)
|
||||||
@ -250,6 +252,7 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
|
|||||||
uint8 mapOffset = HEAPBLK_TO_OFFSET(heapBlk);
|
uint8 mapOffset = HEAPBLK_TO_OFFSET(heapBlk);
|
||||||
Page page;
|
Page page;
|
||||||
uint8 *map;
|
uint8 *map;
|
||||||
|
uint8 status;
|
||||||
|
|
||||||
#ifdef TRACE_VISIBILITYMAP
|
#ifdef TRACE_VISIBILITYMAP
|
||||||
elog(DEBUG1, "vm_set %s %d", RelationGetRelationName(rel), heapBlk);
|
elog(DEBUG1, "vm_set %s %d", RelationGetRelationName(rel), heapBlk);
|
||||||
@ -274,7 +277,8 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
|
|||||||
map = (uint8 *) PageGetContents(page);
|
map = (uint8 *) PageGetContents(page);
|
||||||
LockBuffer(vmBuf, BUFFER_LOCK_EXCLUSIVE);
|
LockBuffer(vmBuf, BUFFER_LOCK_EXCLUSIVE);
|
||||||
|
|
||||||
if (flags != (map[mapByte] >> mapOffset & VISIBILITYMAP_VALID_BITS))
|
status = (map[mapByte] >> mapOffset) & VISIBILITYMAP_VALID_BITS;
|
||||||
|
if (flags != status)
|
||||||
{
|
{
|
||||||
START_CRIT_SECTION();
|
START_CRIT_SECTION();
|
||||||
|
|
||||||
@ -311,6 +315,7 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
LockBuffer(vmBuf, BUFFER_LOCK_UNLOCK);
|
LockBuffer(vmBuf, BUFFER_LOCK_UNLOCK);
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -31,9 +31,12 @@ extern bool visibilitymap_clear(Relation rel, BlockNumber heapBlk,
|
|||||||
extern void visibilitymap_pin(Relation rel, BlockNumber heapBlk,
|
extern void visibilitymap_pin(Relation rel, BlockNumber heapBlk,
|
||||||
Buffer *vmbuf);
|
Buffer *vmbuf);
|
||||||
extern bool visibilitymap_pin_ok(BlockNumber heapBlk, Buffer vmbuf);
|
extern bool visibilitymap_pin_ok(BlockNumber heapBlk, Buffer vmbuf);
|
||||||
extern void visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
|
extern uint8 visibilitymap_set(Relation rel,
|
||||||
XLogRecPtr recptr, Buffer vmBuf, TransactionId cutoff_xid,
|
BlockNumber heapBlk, Buffer heapBuf,
|
||||||
uint8 flags);
|
XLogRecPtr recptr,
|
||||||
|
Buffer vmBuf,
|
||||||
|
TransactionId cutoff_xid,
|
||||||
|
uint8 flags);
|
||||||
extern uint8 visibilitymap_get_status(Relation rel, BlockNumber heapBlk, Buffer *vmbuf);
|
extern uint8 visibilitymap_get_status(Relation rel, BlockNumber heapBlk, Buffer *vmbuf);
|
||||||
extern void visibilitymap_count(Relation rel, BlockNumber *all_visible, BlockNumber *all_frozen);
|
extern void visibilitymap_count(Relation rel, BlockNumber *all_visible, BlockNumber *all_frozen);
|
||||||
extern BlockNumber visibilitymap_prepare_truncate(Relation rel,
|
extern BlockNumber visibilitymap_prepare_truncate(Relation rel,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user