PostgreSQL Source Code  git master
visibilitymap.h File Reference
#include "access/xlogdefs.h"
#include "storage/block.h"
#include "storage/buf.h"
#include "utils/relcache.h"
Include dependency graph for visibilitymap.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BITS_PER_HEAPBLOCK   2
 
#define VISIBILITYMAP_ALL_VISIBLE   0x01
 
#define VISIBILITYMAP_ALL_FROZEN   0x02
 
#define VISIBILITYMAP_VALID_BITS
 
#define VM_ALL_VISIBLE(r, b, v)   ((visibilitymap_get_status((r), (b), (v)) & VISIBILITYMAP_ALL_VISIBLE) != 0)
 
#define VM_ALL_FROZEN(r, b, v)   ((visibilitymap_get_status((r), (b), (v)) & VISIBILITYMAP_ALL_FROZEN) != 0)
 

Functions

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)
 
void visibilitymap_truncate (Relation rel, BlockNumber nheapblocks)
 

Macro Definition Documentation

◆ BITS_PER_HEAPBLOCK

#define BITS_PER_HEAPBLOCK   2

Definition at line 23 of file visibilitymap.h.

Referenced by rewriteVisibilityMap().

◆ VISIBILITYMAP_ALL_FROZEN

◆ VISIBILITYMAP_ALL_VISIBLE

#define VISIBILITYMAP_ALL_VISIBLE   0x01

◆ VISIBILITYMAP_VALID_BITS

◆ VM_ALL_FROZEN

#define VM_ALL_FROZEN (   r,
  b,
 
)    ((visibilitymap_get_status((r), (b), (v)) & VISIBILITYMAP_ALL_FROZEN) != 0)

Definition at line 34 of file visibilitymap.h.

Referenced by collect_corrupt_items(), and lazy_scan_heap().

◆ VM_ALL_VISIBLE

#define VM_ALL_VISIBLE (   r,
  b,
 
)    ((visibilitymap_get_status((r), (b), (v)) & VISIBILITYMAP_ALL_VISIBLE) != 0)

Function Documentation

◆ visibilitymap_clear()

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, and VISIBILITYMAP_VALID_BITS.

Referenced by heap_delete(), 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_heap().

139 {
140  BlockNumber mapBlock = HEAPBLK_TO_MAPBLOCK(heapBlk);
141  int mapByte = HEAPBLK_TO_MAPBYTE(heapBlk);
142  int mapOffset = HEAPBLK_TO_OFFSET(heapBlk);
143  uint8 mask = flags << mapOffset;
144  char *map;
145  bool cleared = false;
146 
148 
149 #ifdef TRACE_VISIBILITYMAP
150  elog(DEBUG1, "vm_clear %s %d", RelationGetRelationName(rel), heapBlk);
151 #endif
152 
153  if (!BufferIsValid(buf) || BufferGetBlockNumber(buf) != mapBlock)
154  elog(ERROR, "wrong buffer passed to visibilitymap_clear");
155 
158 
159  if (map[mapByte] & mask)
160  {
161  map[mapByte] &= ~mask;
162 
164  cleared = true;
165  }
166 
168 
169  return cleared;
170 }
#define BUFFER_LOCK_UNLOCK
Definition: bufmgr.h:86
#define DEBUG1
Definition: elog.h:25
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1458
unsigned char uint8
Definition: c.h:356
#define HEAPBLK_TO_MAPBYTE(x)
uint32 BlockNumber
Definition: block.h:31
#define BUFFER_LOCK_EXCLUSIVE
Definition: bufmgr.h:88
#define VISIBILITYMAP_VALID_BITS
Definition: visibilitymap.h:28
#define ERROR
Definition: elog.h:43
static char * buf
Definition: pg_test_fsync.c:68
#define RelationGetRelationName(relation)
Definition: rel.h:450
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
#define PageGetContents(page)
Definition: bufpage.h:246
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3590
#define Assert(condition)
Definition: c.h:732
#define HEAPBLK_TO_OFFSET(x)
#define BufferIsValid(bufnum)
Definition: bufmgr.h:113
BlockNumber BufferGetBlockNumber(Buffer buffer)
Definition: bufmgr.c:2613
#define elog(elevel,...)
Definition: elog.h:226
#define HEAPBLK_TO_MAPBLOCK(x)

◆ visibilitymap_count()

void visibilitymap_count ( Relation  rel,
BlockNumber all_visible,
BlockNumber all_frozen 
)

Definition at line 377 of file visibilitymap.c.

References Assert, BufferGetPage, BufferIsValid, FROZEN_MASK64, i, MAPSIZE, PageGetContents, pg_popcount64, ReleaseBuffer(), StaticAssertStmt, VISIBLE_MASK64, and vm_readbuf().

Referenced by do_analyze_rel(), heap_vacuum_rel(), and index_update_stats().

378 {
379  BlockNumber mapBlock;
380  BlockNumber nvisible = 0;
381  BlockNumber nfrozen = 0;
382 
383  /* all_visible must be specified */
384  Assert(all_visible);
385 
386  for (mapBlock = 0;; mapBlock++)
387  {
388  Buffer mapBuffer;
389  uint64 *map;
390  int i;
391 
392  /*
393  * Read till we fall off the end of the map. We assume that any extra
394  * bytes in the last page are zeroed, so we don't bother excluding
395  * them from the count.
396  */
397  mapBuffer = vm_readbuf(rel, mapBlock, false);
398  if (!BufferIsValid(mapBuffer))
399  break;
400 
401  /*
402  * We choose not to lock the page, since the result is going to be
403  * immediately stale anyway if anyone is concurrently setting or
404  * clearing bits, and we only really need an approximate value.
405  */
406  map = (uint64 *) PageGetContents(BufferGetPage(mapBuffer));
407 
408  StaticAssertStmt(MAPSIZE % sizeof(uint64) == 0,
409  "unsupported MAPSIZE");
410  if (all_frozen == NULL)
411  {
412  for (i = 0; i < MAPSIZE / sizeof(uint64); i++)
413  nvisible += pg_popcount64(map[i] & VISIBLE_MASK64);
414  }
415  else
416  {
417  for (i = 0; i < MAPSIZE / sizeof(uint64); i++)
418  {
419  nvisible += pg_popcount64(map[i] & VISIBLE_MASK64);
420  nfrozen += pg_popcount64(map[i] & FROZEN_MASK64);
421  }
422  }
423 
424  ReleaseBuffer(mapBuffer);
425  }
426 
427  *all_visible = nvisible;
428  if (all_frozen)
429  *all_frozen = nfrozen;
430 }
uint32 BlockNumber
Definition: block.h:31
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3353
#define StaticAssertStmt(condition, errmessage)
Definition: c.h:842
int(* pg_popcount64)(uint64 word)
Definition: pg_bitutils.c:133
#define VISIBLE_MASK64
#define MAPSIZE
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
#define PageGetContents(page)
Definition: bufpage.h:246
#define Assert(condition)
Definition: c.h:732
#define BufferIsValid(bufnum)
Definition: bufmgr.h:113
#define FROZEN_MASK64
int i
static Buffer vm_readbuf(Relation rel, BlockNumber blkno, bool extend)
int Buffer
Definition: buf.h:23

◆ visibilitymap_get_status()

uint8 visibilitymap_get_status ( Relation  rel,
BlockNumber  heapBlk,
Buffer vmbuf 
)

Definition at line 329 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(), lazy_scan_heap(), lazy_vacuum_page(), pg_visibility(), pg_visibility_map(), and pg_visibility_map_summary().

330 {
331  BlockNumber mapBlock = HEAPBLK_TO_MAPBLOCK(heapBlk);
332  uint32 mapByte = HEAPBLK_TO_MAPBYTE(heapBlk);
333  uint8 mapOffset = HEAPBLK_TO_OFFSET(heapBlk);
334  char *map;
335  uint8 result;
336 
337 #ifdef TRACE_VISIBILITYMAP
338  elog(DEBUG1, "vm_get_status %s %d", RelationGetRelationName(rel), heapBlk);
339 #endif
340 
341  /* Reuse the old pinned buffer if possible */
342  if (BufferIsValid(*buf))
343  {
344  if (BufferGetBlockNumber(*buf) != mapBlock)
345  {
346  ReleaseBuffer(*buf);
347  *buf = InvalidBuffer;
348  }
349  }
350 
351  if (!BufferIsValid(*buf))
352  {
353  *buf = vm_readbuf(rel, mapBlock, false);
354  if (!BufferIsValid(*buf))
355  return false;
356  }
357 
359 
360  /*
361  * A single byte read is atomic. There could be memory-ordering effects
362  * here, but for performance reasons we make it the caller's job to worry
363  * about that.
364  */
365  result = ((map[mapByte] >> mapOffset) & VISIBILITYMAP_VALID_BITS);
366  return result;
367 }
#define DEBUG1
Definition: elog.h:25
unsigned char uint8
Definition: c.h:356
#define HEAPBLK_TO_MAPBYTE(x)
#define InvalidBuffer
Definition: buf.h:25
uint32 BlockNumber
Definition: block.h:31
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3353
#define VISIBILITYMAP_VALID_BITS
Definition: visibilitymap.h:28
static char * buf
Definition: pg_test_fsync.c:68
#define RelationGetRelationName(relation)
Definition: rel.h:450
unsigned int uint32
Definition: c.h:358
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
#define PageGetContents(page)
Definition: bufpage.h:246
#define HEAPBLK_TO_OFFSET(x)
#define BufferIsValid(bufnum)
Definition: bufmgr.h:113
BlockNumber BufferGetBlockNumber(Buffer buffer)
Definition: bufmgr.c:2613
#define elog(elevel,...)
Definition: elog.h:226
static Buffer vm_readbuf(Relation rel, BlockNumber blkno, bool extend)
#define HEAPBLK_TO_MAPBLOCK(x)

◆ visibilitymap_pin()

void visibilitymap_pin ( Relation  rel,
BlockNumber  heapBlk,
Buffer vmbuf 
)

Definition at line 189 of file visibilitymap.c.

References BufferGetBlockNumber(), BufferIsValid, HEAPBLK_TO_MAPBLOCK, ReleaseBuffer(), and vm_readbuf().

Referenced by GetVisibilityMapPins(), heap_delete(), 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(), and RelationGetBufferForTuple().

190 {
191  BlockNumber mapBlock = HEAPBLK_TO_MAPBLOCK(heapBlk);
192 
193  /* Reuse the old pinned buffer if possible */
194  if (BufferIsValid(*buf))
195  {
196  if (BufferGetBlockNumber(*buf) == mapBlock)
197  return;
198 
199  ReleaseBuffer(*buf);
200  }
201  *buf = vm_readbuf(rel, mapBlock, true);
202 }
uint32 BlockNumber
Definition: block.h:31
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3353
static char * buf
Definition: pg_test_fsync.c:68
#define BufferIsValid(bufnum)
Definition: bufmgr.h:113
BlockNumber BufferGetBlockNumber(Buffer buffer)
Definition: bufmgr.c:2613
static Buffer vm_readbuf(Relation rel, BlockNumber blkno, bool extend)
#define HEAPBLK_TO_MAPBLOCK(x)

◆ visibilitymap_pin_ok()

bool visibilitymap_pin_ok ( BlockNumber  heapBlk,
Buffer  vmbuf 
)

Definition at line 213 of file visibilitymap.c.

References BufferGetBlockNumber(), BufferIsValid, and HEAPBLK_TO_MAPBLOCK.

Referenced by GetVisibilityMapPins().

214 {
215  BlockNumber mapBlock = HEAPBLK_TO_MAPBLOCK(heapBlk);
216 
217  return BufferIsValid(buf) && BufferGetBlockNumber(buf) == mapBlock;
218 }
uint32 BlockNumber
Definition: block.h:31
static char * buf
Definition: pg_test_fsync.c:68
#define BufferIsValid(bufnum)
Definition: bufmgr.h:113
BlockNumber BufferGetBlockNumber(Buffer buffer)
Definition: bufmgr.c:2613
#define HEAPBLK_TO_MAPBLOCK(x)

◆ visibilitymap_set()

void visibilitymap_set ( Relation  rel,
BlockNumber  heapBlk,
Buffer  heapBuf,
XLogRecPtr  recptr,
Buffer  vmBuf,
TransactionId  cutoff_xid,
uint8  flags 
)

Definition at line 242 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, RelationData::rd_node, RelationGetRelationName, RelationNeedsWAL, START_CRIT_SECTION, VISIBILITYMAP_VALID_BITS, XLogHintBitIsNeeded, and XLogRecPtrIsInvalid.

Referenced by heap_xlog_visible(), lazy_scan_heap(), and lazy_vacuum_page().

245 {
246  BlockNumber mapBlock = HEAPBLK_TO_MAPBLOCK(heapBlk);
247  uint32 mapByte = HEAPBLK_TO_MAPBYTE(heapBlk);
248  uint8 mapOffset = HEAPBLK_TO_OFFSET(heapBlk);
249  Page page;
250  uint8 *map;
251 
252 #ifdef TRACE_VISIBILITYMAP
253  elog(DEBUG1, "vm_set %s %d", RelationGetRelationName(rel), heapBlk);
254 #endif
255 
257  Assert(InRecovery || BufferIsValid(heapBuf));
259 
260  /* Check that we have the right heap page pinned, if present */
261  if (BufferIsValid(heapBuf) && BufferGetBlockNumber(heapBuf) != heapBlk)
262  elog(ERROR, "wrong heap buffer passed to visibilitymap_set");
263 
264  /* Check that we have the right VM page pinned */
265  if (!BufferIsValid(vmBuf) || BufferGetBlockNumber(vmBuf) != mapBlock)
266  elog(ERROR, "wrong VM buffer passed to visibilitymap_set");
267 
268  page = BufferGetPage(vmBuf);
269  map = (uint8 *) PageGetContents(page);
271 
272  if (flags != (map[mapByte] >> mapOffset & VISIBILITYMAP_VALID_BITS))
273  {
275 
276  map[mapByte] |= (flags << mapOffset);
277  MarkBufferDirty(vmBuf);
278 
279  if (RelationNeedsWAL(rel))
280  {
281  if (XLogRecPtrIsInvalid(recptr))
282  {
283  Assert(!InRecovery);
284  recptr = log_heap_visible(rel->rd_node, heapBuf, vmBuf,
285  cutoff_xid, flags);
286 
287  /*
288  * If data checksums are enabled (or wal_log_hints=on), we
289  * need to protect the heap page from being torn.
290  */
291  if (XLogHintBitIsNeeded())
292  {
293  Page heapPage = BufferGetPage(heapBuf);
294 
295  /* caller is expected to set PD_ALL_VISIBLE first */
296  Assert(PageIsAllVisible(heapPage));
297  PageSetLSN(heapPage, recptr);
298  }
299  }
300  PageSetLSN(page, recptr);
301  }
302 
304  }
305 
307 }
#define BUFFER_LOCK_UNLOCK
Definition: bufmgr.h:86
#define DEBUG1
Definition: elog.h:25
#define PageIsAllVisible(page)
Definition: bufpage.h:385
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1458
bool InRecovery
Definition: xlog.c:200
#define END_CRIT_SECTION()
Definition: miscadmin.h:134
unsigned char uint8
Definition: c.h:356
#define HEAPBLK_TO_MAPBYTE(x)
#define START_CRIT_SECTION()
Definition: miscadmin.h:132
uint32 BlockNumber
Definition: block.h:31
#define BUFFER_LOCK_EXCLUSIVE
Definition: bufmgr.h:88
#define VISIBILITYMAP_VALID_BITS
Definition: visibilitymap.h:28
#define ERROR
Definition: elog.h:43
XLogRecPtr log_heap_visible(RelFileNode rnode, Buffer heap_buffer, Buffer vm_buffer, TransactionId cutoff_xid, uint8 vmflags)
Definition: heapam.c:7269
#define RelationGetRelationName(relation)
Definition: rel.h:450
unsigned int uint32
Definition: c.h:358
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
#define XLogRecPtrIsInvalid(r)
Definition: xlogdefs.h:29
#define PageGetContents(page)
Definition: bufpage.h:246
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3590
RelFileNode rd_node
Definition: rel.h:54
#define Assert(condition)
Definition: c.h:732
#define HEAPBLK_TO_OFFSET(x)
#define BufferIsValid(bufnum)
Definition: bufmgr.h:113
#define RelationNeedsWAL(relation)
Definition: rel.h:518
BlockNumber BufferGetBlockNumber(Buffer buffer)
Definition: bufmgr.c:2613
#define elog(elevel,...)
Definition: elog.h:226
#define PageSetLSN(page, lsn)
Definition: bufpage.h:368
#define XLogHintBitIsNeeded()
Definition: xlog.h:192
Pointer Page
Definition: bufpage.h:78
#define HEAPBLK_TO_MAPBLOCK(x)

◆ visibilitymap_truncate()

void visibilitymap_truncate ( Relation  rel,
BlockNumber  nheapblocks 
)

Definition at line 442 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, LockBuffer(), log_newpage_buffer(), MAPSIZE, MarkBufferDirty(), MemSet, PageGetContents, RelationData::rd_smgr, RelationGetRelationName, RelationNeedsWAL, RelationOpenSmgr, SMgrRelationData::smgr_vm_nblocks, smgrexists(), smgrnblocks(), smgrtruncate(), START_CRIT_SECTION, UnlockReleaseBuffer(), VISIBILITYMAP_FORKNUM, vm_readbuf(), and XLogHintBitIsNeeded.

Referenced by pg_truncate_visibility_map(), RelationTruncate(), and smgr_redo().

443 {
444  BlockNumber newnblocks;
445 
446  /* last remaining block, byte, and bit */
447  BlockNumber truncBlock = HEAPBLK_TO_MAPBLOCK(nheapblocks);
448  uint32 truncByte = HEAPBLK_TO_MAPBYTE(nheapblocks);
449  uint8 truncOffset = HEAPBLK_TO_OFFSET(nheapblocks);
450 
451 #ifdef TRACE_VISIBILITYMAP
452  elog(DEBUG1, "vm_truncate %s %d", RelationGetRelationName(rel), nheapblocks);
453 #endif
454 
455  RelationOpenSmgr(rel);
456 
457  /*
458  * If no visibility map has been created yet for this relation, there's
459  * nothing to truncate.
460  */
462  return;
463 
464  /*
465  * Unless the new size is exactly at a visibility map page boundary, the
466  * tail bits in the last remaining map page, representing truncated heap
467  * blocks, need to be cleared. This is not only tidy, but also necessary
468  * because we don't get a chance to clear the bits if the heap is extended
469  * again.
470  */
471  if (truncByte != 0 || truncOffset != 0)
472  {
473  Buffer mapBuffer;
474  Page page;
475  char *map;
476 
477  newnblocks = truncBlock + 1;
478 
479  mapBuffer = vm_readbuf(rel, truncBlock, false);
480  if (!BufferIsValid(mapBuffer))
481  {
482  /* nothing to do, the file was already smaller */
483  return;
484  }
485 
486  page = BufferGetPage(mapBuffer);
487  map = PageGetContents(page);
488 
489  LockBuffer(mapBuffer, BUFFER_LOCK_EXCLUSIVE);
490 
491  /* NO EREPORT(ERROR) from here till changes are logged */
493 
494  /* Clear out the unwanted bytes. */
495  MemSet(&map[truncByte + 1], 0, MAPSIZE - (truncByte + 1));
496 
497  /*----
498  * Mask out the unwanted bits of the last remaining byte.
499  *
500  * ((1 << 0) - 1) = 00000000
501  * ((1 << 1) - 1) = 00000001
502  * ...
503  * ((1 << 6) - 1) = 00111111
504  * ((1 << 7) - 1) = 01111111
505  *----
506  */
507  map[truncByte] &= (1 << truncOffset) - 1;
508 
509  /*
510  * Truncation of a relation is WAL-logged at a higher-level, and we
511  * will be called at WAL replay. But if checksums are enabled, we need
512  * to still write a WAL record to protect against a torn page, if the
513  * page is flushed to disk before the truncation WAL record. We cannot
514  * use MarkBufferDirtyHint here, because that will not dirty the page
515  * during recovery.
516  */
517  MarkBufferDirty(mapBuffer);
519  log_newpage_buffer(mapBuffer, false);
520 
522 
523  UnlockReleaseBuffer(mapBuffer);
524  }
525  else
526  newnblocks = truncBlock;
527 
528  if (smgrnblocks(rel->rd_smgr, VISIBILITYMAP_FORKNUM) <= newnblocks)
529  {
530  /* nothing to do, the file was already smaller than requested size */
531  return;
532  }
533 
534  /* Truncate the unused VM pages, and send smgr inval message */
535  smgrtruncate(rel->rd_smgr, VISIBILITYMAP_FORKNUM, newnblocks);
536 
537  /*
538  * We might as well update the local smgr_vm_nblocks setting. smgrtruncate
539  * sent an smgr cache inval message, which will cause other backends to
540  * invalidate their copy of smgr_vm_nblocks, and this one too at the next
541  * command boundary. But this ensures it isn't outright wrong until then.
542  */
543  if (rel->rd_smgr)
544  rel->rd_smgr->smgr_vm_nblocks = newnblocks;
545 }
BlockNumber smgr_vm_nblocks
Definition: smgr.h:56
#define DEBUG1
Definition: elog.h:25
XLogRecPtr log_newpage_buffer(Buffer buffer, bool page_std)
Definition: xloginsert.c:1009
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1458
struct SMgrRelationData * rd_smgr
Definition: rel.h:56
bool InRecovery
Definition: xlog.c:200
#define END_CRIT_SECTION()
Definition: miscadmin.h:134
unsigned char uint8
Definition: c.h:356
#define HEAPBLK_TO_MAPBYTE(x)
void smgrtruncate(SMgrRelation reln, ForkNumber forknum, BlockNumber nblocks)
Definition: smgr.c:566
#define START_CRIT_SECTION()
Definition: miscadmin.h:132
#define MemSet(start, val, len)
Definition: c.h:955
uint32 BlockNumber
Definition: block.h:31
bool smgrexists(SMgrRelation reln, ForkNumber forknum)
Definition: smgr.c:247
#define BUFFER_LOCK_EXCLUSIVE
Definition: bufmgr.h:88
#define RelationOpenSmgr(relation)
Definition: rel.h:473
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3376
#define RelationGetRelationName(relation)
Definition: rel.h:450
unsigned int uint32
Definition: c.h:358
#define MAPSIZE
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
#define PageGetContents(page)
Definition: bufpage.h:246
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3590
BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum)
Definition: smgr.c:554
#define HEAPBLK_TO_OFFSET(x)
#define BufferIsValid(bufnum)
Definition: bufmgr.h:113
#define RelationNeedsWAL(relation)
Definition: rel.h:518
#define elog(elevel,...)
Definition: elog.h:226
static Buffer vm_readbuf(Relation rel, BlockNumber blkno, bool extend)
int Buffer
Definition: buf.h:23
#define XLogHintBitIsNeeded()
Definition: xlog.h:192
Pointer Page
Definition: bufpage.h:78
#define HEAPBLK_TO_MAPBLOCK(x)