PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/heapam_xlog.h"
#include "access/visibilitymap.h"
#include "access/xloginsert.h"
#include "access/xlogutils.h"
#include "miscadmin.h"
#include "port/pg_bitutils.h"
#include "storage/bufmgr.h"
#include "storage/smgr.h"
#include "utils/inval.h"
#include "utils/rel.h"
Go to the source code of this file.
Macros | |
#define | MAPSIZE (BLCKSZ - MAXALIGN(SizeOfPageHeaderData)) |
#define | HEAPBLOCKS_PER_BYTE (BITS_PER_BYTE / BITS_PER_HEAPBLOCK) |
#define | HEAPBLOCKS_PER_PAGE (MAPSIZE * HEAPBLOCKS_PER_BYTE) |
#define | HEAPBLK_TO_MAPBLOCK(x) ((x) / HEAPBLOCKS_PER_PAGE) |
#define | HEAPBLK_TO_MAPBYTE(x) (((x) % HEAPBLOCKS_PER_PAGE) / HEAPBLOCKS_PER_BYTE) |
#define | HEAPBLK_TO_OFFSET(x) (((x) % HEAPBLOCKS_PER_BYTE) * BITS_PER_HEAPBLOCK) |
#define | VISIBLE_MASK8 (0x55) /* The lower bit of each bit pair */ |
#define | FROZEN_MASK8 (0xaa) /* The upper bit of each bit pair */ |
Functions | |
static Buffer | vm_readbuf (Relation rel, BlockNumber blkno, bool extend) |
static Buffer | vm_extend (Relation rel, BlockNumber vm_nblocks) |
bool | visibilitymap_clear (Relation rel, BlockNumber heapBlk, Buffer vmbuf, uint8 flags) |
void | visibilitymap_pin (Relation rel, BlockNumber heapBlk, Buffer *vmbuf) |
bool | visibilitymap_pin_ok (BlockNumber heapBlk, Buffer vmbuf) |
void | visibilitymap_set (Relation rel, BlockNumber heapBlk, Buffer heapBuf, XLogRecPtr recptr, Buffer vmBuf, TransactionId cutoff_xid, uint8 flags) |
uint8 | visibilitymap_get_status (Relation rel, BlockNumber heapBlk, Buffer *vmbuf) |
void | visibilitymap_count (Relation rel, BlockNumber *all_visible, BlockNumber *all_frozen) |
BlockNumber | visibilitymap_prepare_truncate (Relation rel, BlockNumber nheapblocks) |
Definition at line 123 of file visibilitymap.c.
#define HEAPBLK_TO_MAPBLOCK | ( | x | ) | ((x) / HEAPBLOCKS_PER_PAGE) |
Definition at line 117 of file visibilitymap.c.
#define HEAPBLK_TO_MAPBYTE | ( | x | ) | (((x) % HEAPBLOCKS_PER_PAGE) / HEAPBLOCKS_PER_BYTE) |
Definition at line 118 of file visibilitymap.c.
#define HEAPBLK_TO_OFFSET | ( | x | ) | (((x) % HEAPBLOCKS_PER_BYTE) * BITS_PER_HEAPBLOCK) |
Definition at line 119 of file visibilitymap.c.
#define HEAPBLOCKS_PER_BYTE (BITS_PER_BYTE / BITS_PER_HEAPBLOCK) |
Definition at line 111 of file visibilitymap.c.
#define HEAPBLOCKS_PER_PAGE (MAPSIZE * HEAPBLOCKS_PER_BYTE) |
Definition at line 114 of file visibilitymap.c.
#define MAPSIZE (BLCKSZ - MAXALIGN(SizeOfPageHeaderData)) |
Definition at line 108 of file visibilitymap.c.
Definition at line 122 of file visibilitymap.c.
bool visibilitymap_clear | ( | Relation | rel, |
BlockNumber | heapBlk, | ||
Buffer | vmbuf, | ||
uint8 | flags | ||
) |
Definition at line 138 of file visibilitymap.c.
References Assert, BUFFER_LOCK_EXCLUSIVE, BUFFER_LOCK_UNLOCK, BufferGetBlockNumber(), BufferGetPage(), BufferIsValid(), DEBUG1, elog, ERROR, HEAPBLK_TO_MAPBLOCK, HEAPBLK_TO_MAPBYTE, HEAPBLK_TO_OFFSET, LockBuffer(), MarkBufferDirty(), PageGetContents(), RelationGetRelationName, VISIBILITYMAP_ALL_VISIBLE, and VISIBILITYMAP_VALID_BITS.
Referenced by heap_delete(), heap_force_common(), heap_insert(), heap_lock_tuple(), heap_lock_updated_tuple_rec(), heap_multi_insert(), heap_update(), heap_xlog_delete(), heap_xlog_insert(), heap_xlog_lock(), heap_xlog_lock_updated(), heap_xlog_multi_insert(), heap_xlog_update(), and lazy_scan_prune().
void visibilitymap_count | ( | Relation | rel, |
BlockNumber * | all_visible, | ||
BlockNumber * | all_frozen | ||
) |
Definition at line 384 of file visibilitymap.c.
References Assert, BufferGetPage(), BufferIsValid(), FROZEN_MASK8, MAPSIZE, PageGetContents(), pg_popcount_masked(), ReleaseBuffer(), VISIBLE_MASK8, and vm_readbuf().
Referenced by do_analyze_rel(), heap_vacuum_rel(), and index_update_stats().
uint8 visibilitymap_get_status | ( | Relation | rel, |
BlockNumber | heapBlk, | ||
Buffer * | vmbuf | ||
) |
Definition at line 336 of file visibilitymap.c.
References BufferGetBlockNumber(), BufferGetPage(), BufferIsValid(), DEBUG1, elog, HEAPBLK_TO_MAPBLOCK, HEAPBLK_TO_MAPBYTE, HEAPBLK_TO_OFFSET, InvalidBuffer, PageGetContents(), RelationGetRelationName, ReleaseBuffer(), VISIBILITYMAP_VALID_BITS, and vm_readbuf().
Referenced by collect_visibility_data(), find_next_unskippable_block(), lazy_scan_prune(), pg_visibility(), pg_visibility_map(), pg_visibility_map_summary(), and verify_heapam().
void visibilitymap_pin | ( | Relation | rel, |
BlockNumber | heapBlk, | ||
Buffer * | vmbuf | ||
) |
Definition at line 191 of file visibilitymap.c.
References BufferGetBlockNumber(), BufferIsValid(), HEAPBLK_TO_MAPBLOCK, ReleaseBuffer(), and vm_readbuf().
Referenced by GetVisibilityMapPins(), heap_delete(), heap_force_common(), heap_lock_tuple(), heap_lock_updated_tuple_rec(), heap_update(), heap_xlog_delete(), heap_xlog_insert(), heap_xlog_lock(), heap_xlog_lock_updated(), heap_xlog_multi_insert(), heap_xlog_update(), heap_xlog_visible(), lazy_scan_heap(), lazy_vacuum_heap_rel(), and RelationGetBufferForTuple().
bool visibilitymap_pin_ok | ( | BlockNumber | heapBlk, |
Buffer | vmbuf | ||
) |
Definition at line 215 of file visibilitymap.c.
References BufferGetBlockNumber(), BufferIsValid(), and HEAPBLK_TO_MAPBLOCK.
Referenced by GetVisibilityMapPins(), heap_multi_insert(), and RelationGetBufferForTuple().
BlockNumber visibilitymap_prepare_truncate | ( | Relation | rel, |
BlockNumber | nheapblocks | ||
) |
Definition at line 438 of file visibilitymap.c.
References BUFFER_LOCK_EXCLUSIVE, BufferGetPage(), BufferIsValid(), DEBUG1, elog, END_CRIT_SECTION, HEAPBLK_TO_MAPBLOCK, HEAPBLK_TO_MAPBYTE, HEAPBLK_TO_OFFSET, InRecovery, InvalidBlockNumber, LockBuffer(), log_newpage_buffer(), MAPSIZE, MarkBufferDirty(), MemSet, PageGetContents(), RelationGetRelationName, RelationGetSmgr(), RelationNeedsWAL, smgrexists(), smgrnblocks(), START_CRIT_SECTION, UnlockReleaseBuffer(), VISIBILITYMAP_FORKNUM, vm_readbuf(), and XLogHintBitIsNeeded.
Referenced by pg_truncate_visibility_map(), RelationTruncate(), and smgr_redo().
void visibilitymap_set | ( | Relation | rel, |
BlockNumber | heapBlk, | ||
Buffer | heapBuf, | ||
XLogRecPtr | recptr, | ||
Buffer | vmBuf, | ||
TransactionId | cutoff_xid, | ||
uint8 | flags | ||
) |
Definition at line 244 of file visibilitymap.c.
References Assert, BUFFER_LOCK_EXCLUSIVE, BUFFER_LOCK_UNLOCK, BufferGetBlockNumber(), BufferGetPage(), BufferIsValid(), DEBUG1, elog, END_CRIT_SECTION, ERROR, HEAPBLK_TO_MAPBLOCK, HEAPBLK_TO_MAPBYTE, HEAPBLK_TO_OFFSET, InRecovery, LockBuffer(), log_heap_visible(), MarkBufferDirty(), PageGetContents(), PageIsAllVisible(), PageSetLSN(), RelationGetRelationName, RelationNeedsWAL, START_CRIT_SECTION, VISIBILITYMAP_ALL_FROZEN, VISIBILITYMAP_VALID_BITS, XLogHintBitIsNeeded, and XLogRecPtrIsInvalid.
Referenced by heap_multi_insert(), heap_xlog_visible(), lazy_scan_new_or_empty(), lazy_scan_prune(), and lazy_vacuum_heap_page().
|
static |
Definition at line 612 of file visibilitymap.c.
References BMR_REL, buf, CacheInvalidateSmgr(), EB_CLEAR_SIZE_CACHE, EB_CREATE_FORK_IF_NEEDED, ExtendBufferedRelTo(), RBM_ZERO_ON_ERROR, RelationGetSmgr(), and VISIBILITYMAP_FORKNUM.
Referenced by vm_readbuf().
|
static |
Definition at line 538 of file visibilitymap.c.
References buf, BUFFER_LOCK_EXCLUSIVE, BUFFER_LOCK_UNLOCK, BufferGetPage(), InvalidBlockNumber, InvalidBuffer, LockBuffer(), PageInit(), PageIsNew(), RBM_ZERO_ON_ERROR, ReadBufferExtended(), RelationGetSmgr(), SMgrRelationData::smgr_cached_nblocks, smgrexists(), smgrnblocks(), VISIBILITYMAP_FORKNUM, and vm_extend().
Referenced by visibilitymap_count(), visibilitymap_get_status(), visibilitymap_pin(), and visibilitymap_prepare_truncate().