PostgreSQL Source Code  git master
xloginsert.c File Reference
#include "postgres.h"
#include "access/xact.h"
#include "access/xlog.h"
#include "access/xlog_internal.h"
#include "access/xloginsert.h"
#include "catalog/pg_control.h"
#include "common/pg_lzcompress.h"
#include "executor/instrument.h"
#include "miscadmin.h"
#include "pg_trace.h"
#include "replication/origin.h"
#include "storage/bufmgr.h"
#include "storage/proc.h"
#include "utils/memutils.h"
Include dependency graph for xloginsert.c:

Go to the source code of this file.

Data Structures

struct  registered_buffer
 

Macros

#define PGLZ_MAX_BLCKSZ   PGLZ_MAX_OUTPUT(BLCKSZ)
 
#define SizeOfXlogOrigin   (sizeof(RepOriginId) + sizeof(char))
 
#define SizeOfXLogTransactionId   (sizeof(TransactionId) + sizeof(char))
 
#define HEADER_SCRATCH_SIZE
 

Functions

static XLogRecDataXLogRecordAssemble (RmgrId rmid, uint8 info, XLogRecPtr RedoRecPtr, bool doPageWrites, XLogRecPtr *fpw_lsn, int *num_fpi)
 
static bool XLogCompressBackupBlock (char *page, uint16 hole_offset, uint16 hole_length, char *dest, uint16 *dlen)
 
void XLogBeginInsert (void)
 
void XLogEnsureRecordSpace (int max_block_id, int ndatas)
 
void XLogResetInsertion (void)
 
void XLogRegisterBuffer (uint8 block_id, Buffer buffer, uint8 flags)
 
void XLogRegisterBlock (uint8 block_id, RelFileNode *rnode, ForkNumber forknum, BlockNumber blknum, Page page, uint8 flags)
 
void XLogRegisterData (char *data, int len)
 
void XLogRegisterBufData (uint8 block_id, char *data, int len)
 
void XLogSetRecordFlags (uint8 flags)
 
XLogRecPtr XLogInsert (RmgrId rmid, uint8 info)
 
bool XLogCheckBufferNeedsBackup (Buffer buffer)
 
XLogRecPtr XLogSaveBufferForHint (Buffer buffer, bool buffer_std)
 
XLogRecPtr log_newpage (RelFileNode *rnode, ForkNumber forkNum, BlockNumber blkno, Page page, bool page_std)
 
void log_newpages (RelFileNode *rnode, ForkNumber forkNum, int num_pages, BlockNumber *blknos, Page *pages, bool page_std)
 
XLogRecPtr log_newpage_buffer (Buffer buffer, bool page_std)
 
void log_newpage_range (Relation rel, ForkNumber forkNum, BlockNumber startblk, BlockNumber endblk, bool page_std)
 
void InitXLogInsert (void)
 

Variables

static registered_bufferregistered_buffers
 
static int max_registered_buffers
 
static int max_registered_block_id = 0
 
static XLogRecDatamainrdata_head
 
static XLogRecDatamainrdata_last = (XLogRecData *) &mainrdata_head
 
static uint32 mainrdata_len
 
static uint8 curinsert_flags = 0
 
static XLogRecData hdr_rdt
 
static char * hdr_scratch = NULL
 
static XLogRecDatardatas
 
static int num_rdatas
 
static int max_rdatas
 
static bool begininsert_called = false
 
static MemoryContext xloginsert_cxt
 

Macro Definition Documentation

◆ HEADER_SCRATCH_SIZE

#define HEADER_SCRATCH_SIZE
Value:
MaxSizeOfXLogRecordBlockHeader * (XLR_MAX_BLOCK_ID + 1) + \
#define SizeOfXlogOrigin
Definition: xloginsert.c:91
#define SizeOfXLogTransactionId
Definition: xloginsert.c:92
#define XLR_MAX_BLOCK_ID
Definition: xlogrecord.h:221
#define SizeOfXLogRecord
Definition: xlogrecord.h:55
#define SizeOfXLogRecordDataHeaderLong
Definition: xlogrecord.h:208

Definition at line 94 of file xloginsert.c.

Referenced by InitXLogInsert().

◆ PGLZ_MAX_BLCKSZ

#define PGLZ_MAX_BLCKSZ   PGLZ_MAX_OUTPUT(BLCKSZ)

Definition at line 37 of file xloginsert.c.

◆ SizeOfXlogOrigin

#define SizeOfXlogOrigin   (sizeof(RepOriginId) + sizeof(char))

Definition at line 91 of file xloginsert.c.

◆ SizeOfXLogTransactionId

#define SizeOfXLogTransactionId   (sizeof(TransactionId) + sizeof(char))

Definition at line 92 of file xloginsert.c.

Function Documentation

◆ InitXLogInsert()

void InitXLogInsert ( void  )

Definition at line 1197 of file xloginsert.c.

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, hdr_scratch, HEADER_SCRATCH_SIZE, max_rdatas, max_registered_buffers, MemoryContextAlloc(), MemoryContextAllocZero(), TopMemoryContext, XLR_NORMAL_MAX_BLOCK_ID, and XLR_NORMAL_RDATAS.

Referenced by CreateCheckPoint(), and InitXLOGAccess().

1198 {
1199  /* Initialize the working areas */
1200  if (xloginsert_cxt == NULL)
1201  {
1203  "WAL record construction",
1205  }
1206 
1207  if (registered_buffers == NULL)
1208  {
1211  sizeof(registered_buffer) * (XLR_NORMAL_MAX_BLOCK_ID + 1));
1213  }
1214  if (rdatas == NULL)
1215  {
1217  sizeof(XLogRecData) * XLR_NORMAL_RDATAS);
1219  }
1220 
1221  /*
1222  * Allocate a buffer to hold the header information for a WAL record.
1223  */
1224  if (hdr_scratch == NULL)
1227 }
#define AllocSetContextCreate
Definition: memutils.h:170
#define HEADER_SCRATCH_SIZE
Definition: xloginsert.c:94
#define XLR_NORMAL_RDATAS
Definition: xloginsert.h:28
static int max_registered_buffers
Definition: xloginsert.c:65
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:192
static int max_rdatas
Definition: xloginsert.c:105
MemoryContext TopMemoryContext
Definition: mcxt.c:44
static registered_buffer * registered_buffers
Definition: xloginsert.c:64
void * MemoryContextAllocZero(MemoryContext context, Size size)
Definition: mcxt.c:840
#define XLR_NORMAL_MAX_BLOCK_ID
Definition: xloginsert.h:27
static char * hdr_scratch
Definition: xloginsert.c:89
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:797
static MemoryContext xloginsert_cxt
Definition: xloginsert.c:110
static XLogRecData * rdatas
Definition: xloginsert.c:103

◆ log_newpage()

XLogRecPtr log_newpage ( RelFileNode rnode,
ForkNumber  forkNum,
BlockNumber  blkno,
Page  page,
bool  page_std 
)

Definition at line 996 of file xloginsert.c.

References PageIsNew, PageSetLSN, REGBUF_FORCE_IMAGE, REGBUF_STANDARD, XLOG_FPI, XLogBeginInsert(), XLogInsert(), and XLogRegisterBlock().

Referenced by _bt_blwritepage(), _hash_alloc_buckets(), _hash_init(), blbuildempty(), btbuildempty(), end_heap_rewrite(), gist_indexsortbuild(), log_newpage_buffer(), raw_heap_insert(), RelationCopyStorage(), and spgbuildempty().

998 {
999  int flags;
1000  XLogRecPtr recptr;
1001 
1002  flags = REGBUF_FORCE_IMAGE;
1003  if (page_std)
1004  flags |= REGBUF_STANDARD;
1005 
1006  XLogBeginInsert();
1007  XLogRegisterBlock(0, rnode, forkNum, blkno, page, flags);
1008  recptr = XLogInsert(RM_XLOG_ID, XLOG_FPI);
1009 
1010  /*
1011  * The page may be uninitialized. If so, we can't set the LSN because that
1012  * would corrupt the page.
1013  */
1014  if (!PageIsNew(page))
1015  {
1016  PageSetLSN(page, recptr);
1017  }
1018 
1019  return recptr;
1020 }
void XLogRegisterBlock(uint8 block_id, RelFileNode *rnode, ForkNumber forknum, BlockNumber blknum, Page page, uint8 flags)
Definition: xloginsert.c:273
#define REGBUF_STANDARD
Definition: xloginsert.h:35
#define REGBUF_FORCE_IMAGE
Definition: xloginsert.h:31
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:422
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define XLOG_FPI
Definition: pg_control.h:78
#define PageIsNew(page)
Definition: bufpage.h:229
void XLogBeginInsert(void)
Definition: xloginsert.c:123
#define PageSetLSN(page, lsn)
Definition: bufpage.h:368

◆ log_newpage_buffer()

XLogRecPtr log_newpage_buffer ( Buffer  buffer,
bool  page_std 
)

Definition at line 1090 of file xloginsert.c.

References Assert, BufferGetPage, BufferGetTag(), CritSectionCount, and log_newpage().

Referenced by brin_initialize_empty_new_buffer(), brinbuildempty(), FreeSpaceMapPrepareTruncateRel(), ginbuildempty(), gistbuildempty(), heap_force_common(), lazy_scan_heap(), and visibilitymap_prepare_truncate().

1091 {
1092  Page page = BufferGetPage(buffer);
1093  RelFileNode rnode;
1094  ForkNumber forkNum;
1095  BlockNumber blkno;
1096 
1097  /* Shared buffers should be modified in a critical section. */
1098  Assert(CritSectionCount > 0);
1099 
1100  BufferGetTag(buffer, &rnode, &forkNum, &blkno);
1101 
1102  return log_newpage(&rnode, forkNum, blkno, page, page_std);
1103 }
uint32 BlockNumber
Definition: block.h:31
volatile uint32 CritSectionCount
Definition: globals.c:38
#define BufferGetPage(buffer)
Definition: bufmgr.h:169
ForkNumber
Definition: relpath.h:40
#define Assert(condition)
Definition: c.h:800
XLogRecPtr log_newpage(RelFileNode *rnode, ForkNumber forkNum, BlockNumber blkno, Page page, bool page_std)
Definition: xloginsert.c:996
void BufferGetTag(Buffer buffer, RelFileNode *rnode, ForkNumber *forknum, BlockNumber *blknum)
Definition: bufmgr.c:2684
Pointer Page
Definition: bufpage.h:78

◆ log_newpage_range()

void log_newpage_range ( Relation  rel,
ForkNumber  forkNum,
BlockNumber  startblk,
BlockNumber  endblk,
bool  page_std 
)

Definition at line 1123 of file xloginsert.c.

References buf, BUFFER_LOCK_EXCLUSIVE, BufferGetPage, CHECK_FOR_INTERRUPTS, END_CRIT_SECTION, i, LockBuffer(), MarkBufferDirty(), PageIsNew, PageSetLSN, RBM_NORMAL, ReadBufferExtended(), REGBUF_FORCE_IMAGE, REGBUF_STANDARD, START_CRIT_SECTION, UnlockReleaseBuffer(), XLOG_FPI, XLogBeginInsert(), XLogEnsureRecordSpace(), XLogInsert(), XLogRegisterBuffer(), and XLR_MAX_BLOCK_ID.

Referenced by ginbuild(), gistbuild(), smgrDoPendingSyncs(), and spgbuild().

1126 {
1127  int flags;
1128  BlockNumber blkno;
1129 
1130  flags = REGBUF_FORCE_IMAGE;
1131  if (page_std)
1132  flags |= REGBUF_STANDARD;
1133 
1134  /*
1135  * Iterate over all the pages in the range. They are collected into
1136  * batches of XLR_MAX_BLOCK_ID pages, and a single WAL-record is written
1137  * for each batch.
1138  */
1140 
1141  blkno = startblk;
1142  while (blkno < endblk)
1143  {
1144  Buffer bufpack[XLR_MAX_BLOCK_ID];
1145  XLogRecPtr recptr;
1146  int nbufs;
1147  int i;
1148 
1150 
1151  /* Collect a batch of blocks. */
1152  nbufs = 0;
1153  while (nbufs < XLR_MAX_BLOCK_ID && blkno < endblk)
1154  {
1155  Buffer buf = ReadBufferExtended(rel, forkNum, blkno,
1156  RBM_NORMAL, NULL);
1157 
1159 
1160  /*
1161  * Completely empty pages are not WAL-logged. Writing a WAL record
1162  * would change the LSN, and we don't want that. We want the page
1163  * to stay empty.
1164  */
1165  if (!PageIsNew(BufferGetPage(buf)))
1166  bufpack[nbufs++] = buf;
1167  else
1168  UnlockReleaseBuffer(buf);
1169  blkno++;
1170  }
1171 
1172  /* Write WAL record for this batch. */
1173  XLogBeginInsert();
1174 
1176  for (i = 0; i < nbufs; i++)
1177  {
1178  XLogRegisterBuffer(i, bufpack[i], flags);
1179  MarkBufferDirty(bufpack[i]);
1180  }
1181 
1182  recptr = XLogInsert(RM_XLOG_ID, XLOG_FPI);
1183 
1184  for (i = 0; i < nbufs; i++)
1185  {
1186  PageSetLSN(BufferGetPage(bufpack[i]), recptr);
1187  UnlockReleaseBuffer(bufpack[i]);
1188  }
1189  END_CRIT_SECTION();
1190  }
1191 }
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1471
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:220
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
Definition: bufmgr.c:654
#define END_CRIT_SECTION()
Definition: miscadmin.h:134
#define START_CRIT_SECTION()
Definition: miscadmin.h:132
uint32 BlockNumber
Definition: block.h:31
#define BUFFER_LOCK_EXCLUSIVE
Definition: bufmgr.h:98
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3536
static char * buf
Definition: pg_test_fsync.c:68
#define REGBUF_STANDARD
Definition: xloginsert.h:35
#define BufferGetPage(buffer)
Definition: bufmgr.h:169
#define XLR_MAX_BLOCK_ID
Definition: xlogrecord.h:221
#define REGBUF_FORCE_IMAGE
Definition: xloginsert.h:31
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:422
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3752
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void XLogEnsureRecordSpace(int max_block_id, int ndatas)
Definition: xloginsert.c:149
#define XLOG_FPI
Definition: pg_control.h:78
#define PageIsNew(page)
Definition: bufpage.h:229
int i
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:99
void XLogBeginInsert(void)
Definition: xloginsert.c:123
#define PageSetLSN(page, lsn)
Definition: bufpage.h:368
int Buffer
Definition: buf.h:23

◆ log_newpages()

void log_newpages ( RelFileNode rnode,
ForkNumber  forkNum,
int  num_pages,
BlockNumber blknos,
Page pages,
bool  page_std 
)

Definition at line 1028 of file xloginsert.c.

References i, PageIsNew, PageSetLSN, REGBUF_FORCE_IMAGE, REGBUF_STANDARD, XLOG_FPI, XLogBeginInsert(), XLogEnsureRecordSpace(), XLogInsert(), XLogRegisterBlock(), and XLR_MAX_BLOCK_ID.

Referenced by gist_indexsortbuild_flush_ready_pages().

1030 {
1031  int flags;
1032  XLogRecPtr recptr;
1033  int i;
1034  int j;
1035 
1036  flags = REGBUF_FORCE_IMAGE;
1037  if (page_std)
1038  flags |= REGBUF_STANDARD;
1039 
1040  /*
1041  * Iterate over all the pages. They are collected into batches of
1042  * XLR_MAX_BLOCK_ID pages, and a single WAL-record is written for each
1043  * batch.
1044  */
1046 
1047  i = 0;
1048  while (i < num_pages)
1049  {
1050  int batch_start = i;
1051  int nbatch;
1052 
1053  XLogBeginInsert();
1054 
1055  nbatch = 0;
1056  while (nbatch < XLR_MAX_BLOCK_ID && i < num_pages)
1057  {
1058  XLogRegisterBlock(nbatch, rnode, forkNum, blknos[i], pages[i], flags);
1059  i++;
1060  nbatch++;
1061  }
1062 
1063  recptr = XLogInsert(RM_XLOG_ID, XLOG_FPI);
1064 
1065  for (j = batch_start; j < i; j++)
1066  {
1067  /*
1068  * The page may be uninitialized. If so, we can't set the LSN because that
1069  * would corrupt the page.
1070  */
1071  if (!PageIsNew(pages[j]))
1072  {
1073  PageSetLSN(pages[j], recptr);
1074  }
1075  }
1076  }
1077 }
void XLogRegisterBlock(uint8 block_id, RelFileNode *rnode, ForkNumber forknum, BlockNumber blknum, Page page, uint8 flags)
Definition: xloginsert.c:273
#define REGBUF_STANDARD
Definition: xloginsert.h:35
#define XLR_MAX_BLOCK_ID
Definition: xlogrecord.h:221
#define REGBUF_FORCE_IMAGE
Definition: xloginsert.h:31
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:422
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void XLogEnsureRecordSpace(int max_block_id, int ndatas)
Definition: xloginsert.c:149
#define XLOG_FPI
Definition: pg_control.h:78
#define PageIsNew(page)
Definition: bufpage.h:229
int i
void XLogBeginInsert(void)
Definition: xloginsert.c:123
#define PageSetLSN(page, lsn)
Definition: bufpage.h:368

◆ XLogBeginInsert()

void XLogBeginInsert ( void  )

Definition at line 123 of file xloginsert.c.

References Assert, begininsert_called, elog, ERROR, mainrdata_len, max_registered_block_id, and XLogInsertAllowed().

Referenced by _bt_dedup_pass(), _bt_delitems_delete(), _bt_delitems_vacuum(), _bt_getroot(), _bt_insertonpg(), _bt_log_reuse_page(), _bt_mark_page_halfdead(), _bt_newroot(), _bt_split(), _bt_unlink_halfdead_page(), _bt_update_meta_cleanup_info(), _hash_addovflpage(), _hash_doinsert(), _hash_expandtable(), _hash_freeovflpage(), _hash_init(), _hash_splitbucket(), _hash_squeezebucket(), _hash_vacuum_one_page(), addLeafTuple(), AssignTransactionId(), brin_doinsert(), brin_doupdate(), brinbuild(), brinRevmapDesummarizeRange(), CreateCheckPoint(), createdb(), CreateEndOfRecoveryRecord(), createPostingTree(), CreateTableSpace(), do_pg_stop_backup(), do_setval(), doPickSplit(), DropTableSpace(), EndPrepare(), ExecuteTruncateGuts(), fill_seq_with_data(), GenericXLogFinish(), ginDeletePage(), ginHeapTupleFastInsert(), ginPlaceToPage(), ginUpdateStats(), ginVacuumPostingTreeLeaf(), gistXLogAssignLSN(), gistXLogDelete(), gistXLogPageDelete(), gistXLogPageReuse(), gistXLogSplit(), gistXLogUpdate(), hashbucketcleanup(), hashbulkdelete(), heap_abort_speculative(), heap_delete(), heap_finish_speculative(), heap_inplace_update(), heap_insert(), heap_lock_tuple(), heap_lock_updated_tuple_rec(), heap_multi_insert(), heap_update(), log_heap_clean(), log_heap_cleanup_info(), log_heap_freeze(), log_heap_new_cid(), log_heap_update(), log_heap_visible(), log_newpage(), log_newpage_range(), log_newpages(), log_smgrcreate(), log_split_page(), LogAccessExclusiveLocks(), LogCurrentRunningXacts(), logical_heap_rewrite_flush_mappings(), LogLogicalInvalidations(), LogLogicalMessage(), LogStandbyInvalidations(), movedb(), moveLeafs(), MultiXactIdCreateFromMembers(), nextval_internal(), pg_truncate_visibility_map(), RelationTruncate(), remove_dbtablespaces(), replorigin_advance(), replorigin_drop(), RequestXLogSwitch(), revmap_physical_extend(), shiftList(), spgAddNodeAction(), spgSplitNodeAction(), UpdateFullPageWrites(), vacuumLeafPage(), vacuumLeafRoot(), vacuumRedirectAndPlaceholder(), write_relmap_file(), writeListPage(), WriteMTruncateXlogRec(), WriteMZeroPageXlogRec(), WriteSetTimestampXlogRec(), WriteTruncateXlogRec(), WriteZeroPageXlogRec(), XactLogAbortRecord(), XactLogCommitRecord(), XLogPutNextOid(), XLogReportParameters(), XLogRestorePoint(), XLogSaveBufferForHint(), and xlogVacuumPage().

124 {
127  Assert(mainrdata_len == 0);
128 
129  /* cross-check on whether we should be here or not */
130  if (!XLogInsertAllowed())
131  elog(ERROR, "cannot make new WAL entries during recovery");
132 
133  if (begininsert_called)
134  elog(ERROR, "XLogBeginInsert was already called");
135 
136  begininsert_called = true;
137 }
static uint32 mainrdata_len
Definition: xloginsert.c:75
static bool begininsert_called
Definition: xloginsert.c:107
#define ERROR
Definition: elog.h:43
static XLogRecData * mainrdata_head
Definition: xloginsert.c:73
bool XLogInsertAllowed(void)
Definition: xlog.c:8184
static XLogRecData * mainrdata_last
Definition: xloginsert.c:74
#define Assert(condition)
Definition: c.h:800
static int max_registered_block_id
Definition: xloginsert.c:66
#define elog(elevel,...)
Definition: elog.h:228

◆ XLogCheckBufferNeedsBackup()

bool XLogCheckBufferNeedsBackup ( Buffer  buffer)

Definition at line 879 of file xloginsert.c.

References BufferGetPage, doPageWrites, GetFullPageWriteInfo(), PageGetLSN, and RedoRecPtr.

Referenced by log_heap_update().

880 {
882  bool doPageWrites;
883  Page page;
884 
885  GetFullPageWriteInfo(&RedoRecPtr, &doPageWrites);
886 
887  page = BufferGetPage(buffer);
888 
889  if (doPageWrites && PageGetLSN(page) <= RedoRecPtr)
890  return true; /* buffer requires backup */
891 
892  return false; /* buffer does not need to be backed up */
893 }
static bool doPageWrites
Definition: xlog.c:381
static XLogRecPtr RedoRecPtr
Definition: xlog.c:374
#define BufferGetPage(buffer)
Definition: bufmgr.h:169
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define PageGetLSN(page)
Definition: bufpage.h:366
void GetFullPageWriteInfo(XLogRecPtr *RedoRecPtr_p, bool *doPageWrites_p)
Definition: xlog.c:8392
Pointer Page
Definition: bufpage.h:78

◆ XLogCompressBackupBlock()

static bool XLogCompressBackupBlock ( char *  page,
uint16  hole_offset,
uint16  hole_length,
char *  dest,
uint16 dlen 
)
static

Definition at line 829 of file xloginsert.c.

References PGAlignedBlock::data, pglz_compress(), PGLZ_strategy_default, SizeOfXLogRecordBlockCompressHeader, and source.

Referenced by XLogRecordAssemble().

831 {
832  int32 orig_len = BLCKSZ - hole_length;
833  int32 len;
834  int32 extra_bytes = 0;
835  char *source;
836  PGAlignedBlock tmp;
837 
838  if (hole_length != 0)
839  {
840  /* must skip the hole */
841  source = tmp.data;
842  memcpy(source, page, hole_offset);
843  memcpy(source + hole_offset,
844  page + (hole_offset + hole_length),
845  BLCKSZ - (hole_length + hole_offset));
846 
847  /*
848  * Extra data needs to be stored in WAL record for the compressed
849  * version of block image if the hole exists.
850  */
852  }
853  else
854  source = page;
855 
856  /*
857  * We recheck the actual size even if pglz_compress() reports success and
858  * see if the number of bytes saved by compression is larger than the
859  * length of extra data needed for the compressed version of block image.
860  */
861  len = pglz_compress(source, orig_len, dest, PGLZ_strategy_default);
862  if (len >= 0 &&
863  len + extra_bytes < orig_len)
864  {
865  *dlen = (uint16) len; /* successful compression */
866  return true;
867  }
868  return false;
869 }
signed int int32
Definition: c.h:417
char data[BLCKSZ]
Definition: c.h:1137
unsigned short uint16
Definition: c.h:428
int32 pglz_compress(const char *source, int32 slen, char *dest, const PGLZ_Strategy *strategy)
static rewind_source * source
Definition: pg_rewind.c:79
const PGLZ_Strategy *const PGLZ_strategy_default
#define SizeOfXLogRecordBlockCompressHeader
Definition: xlogrecord.h:160

◆ XLogEnsureRecordSpace()

void XLogEnsureRecordSpace ( int  max_block_id,
int  ndatas 
)

Definition at line 149 of file xloginsert.c.

References Assert, CritSectionCount, elog, ERROR, max_rdatas, max_registered_buffers, MemSet, repalloc(), XLR_MAX_BLOCK_ID, XLR_NORMAL_MAX_BLOCK_ID, and XLR_NORMAL_RDATAS.

Referenced by _hash_freeovflpage(), _hash_squeezebucket(), EndPrepare(), gistplacetopage(), log_newpage_range(), log_newpages(), and shiftList().

150 {
151  int nbuffers;
152 
153  /*
154  * This must be called before entering a critical section, because
155  * allocating memory inside a critical section can fail. repalloc() will
156  * check the same, but better to check it here too so that we fail
157  * consistently even if the arrays happen to be large enough already.
158  */
159  Assert(CritSectionCount == 0);
160 
161  /* the minimum values can't be decreased */
162  if (max_block_id < XLR_NORMAL_MAX_BLOCK_ID)
163  max_block_id = XLR_NORMAL_MAX_BLOCK_ID;
164  if (ndatas < XLR_NORMAL_RDATAS)
165  ndatas = XLR_NORMAL_RDATAS;
166 
167  if (max_block_id > XLR_MAX_BLOCK_ID)
168  elog(ERROR, "maximum number of WAL record block references exceeded");
169  nbuffers = max_block_id + 1;
170 
171  if (nbuffers > max_registered_buffers)
172  {
174  repalloc(registered_buffers, sizeof(registered_buffer) * nbuffers);
175 
176  /*
177  * At least the padding bytes in the structs must be zeroed, because
178  * they are included in WAL data, but initialize it all for tidiness.
179  */
181  (nbuffers - max_registered_buffers) * sizeof(registered_buffer));
182  max_registered_buffers = nbuffers;
183  }
184 
185  if (ndatas > max_rdatas)
186  {
187  rdatas = (XLogRecData *) repalloc(rdatas, sizeof(XLogRecData) * ndatas);
188  max_rdatas = ndatas;
189  }
190 }
#define XLR_NORMAL_RDATAS
Definition: xloginsert.h:28
#define MemSet(start, val, len)
Definition: c.h:1004
#define ERROR
Definition: elog.h:43
static int max_registered_buffers
Definition: xloginsert.c:65
volatile uint32 CritSectionCount
Definition: globals.c:38
static int max_rdatas
Definition: xloginsert.c:105
#define XLR_MAX_BLOCK_ID
Definition: xlogrecord.h:221
static registered_buffer * registered_buffers
Definition: xloginsert.c:64
#define XLR_NORMAL_MAX_BLOCK_ID
Definition: xloginsert.h:27
#define Assert(condition)
Definition: c.h:800
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:1070
#define elog(elevel,...)
Definition: elog.h:228
static XLogRecData * rdatas
Definition: xloginsert.c:103

◆ XLogInsert()

XLogRecPtr XLogInsert ( RmgrId  rmid,
uint8  info 
)

Definition at line 422 of file xloginsert.c.

References begininsert_called, curinsert_flags, doPageWrites, elog, ERROR, GetFullPageWriteInfo(), InvalidXLogRecPtr, IsBootstrapProcessingMode, PANIC, RedoRecPtr, SizeOfXLogLongPHD, XLogInsertRecord(), XLogRecordAssemble(), XLogResetInsertion(), XLR_CHECK_CONSISTENCY, XLR_RMGR_INFO_MASK, and XLR_SPECIAL_REL_UPDATE.

Referenced by _bt_dedup_pass(), _bt_delitems_delete(), _bt_delitems_vacuum(), _bt_getroot(), _bt_insertonpg(), _bt_log_reuse_page(), _bt_mark_page_halfdead(), _bt_newroot(), _bt_split(), _bt_unlink_halfdead_page(), _bt_update_meta_cleanup_info(), _hash_addovflpage(), _hash_doinsert(), _hash_expandtable(), _hash_freeovflpage(), _hash_init(), _hash_splitbucket(), _hash_squeezebucket(), _hash_vacuum_one_page(), addLeafTuple(), AssignTransactionId(), brin_doinsert(), brin_doupdate(), brinbuild(), brinRevmapDesummarizeRange(), CreateCheckPoint(), createdb(), CreateEndOfRecoveryRecord(), createPostingTree(), CreateTableSpace(), do_pg_stop_backup(), do_setval(), doPickSplit(), DropTableSpace(), EndPrepare(), ExecuteTruncateGuts(), fill_seq_with_data(), GenericXLogFinish(), ginDeletePage(), ginHeapTupleFastInsert(), ginPlaceToPage(), ginUpdateStats(), ginVacuumPostingTreeLeaf(), gistXLogAssignLSN(), gistXLogDelete(), gistXLogPageDelete(), gistXLogPageReuse(), gistXLogSplit(), gistXLogUpdate(), hashbucketcleanup(), hashbulkdelete(), heap_abort_speculative(), heap_delete(), heap_finish_speculative(), heap_inplace_update(), heap_insert(), heap_lock_tuple(), heap_lock_updated_tuple_rec(), heap_multi_insert(), heap_update(), log_heap_clean(), log_heap_cleanup_info(), log_heap_freeze(), log_heap_new_cid(), log_heap_update(), log_heap_visible(), log_newpage(), log_newpage_range(), log_newpages(), log_smgrcreate(), log_split_page(), LogAccessExclusiveLocks(), LogCurrentRunningXacts(), logical_heap_rewrite_flush_mappings(), LogLogicalInvalidations(), LogLogicalMessage(), LogStandbyInvalidations(), movedb(), moveLeafs(), MultiXactIdCreateFromMembers(), nextval_internal(), pg_truncate_visibility_map(), RelationTruncate(), remove_dbtablespaces(), replorigin_advance(), replorigin_drop(), RequestXLogSwitch(), revmap_physical_extend(), shiftList(), spgAddNodeAction(), spgSplitNodeAction(), UpdateFullPageWrites(), vacuumLeafPage(), vacuumLeafRoot(), vacuumRedirectAndPlaceholder(), write_relmap_file(), writeListPage(), WriteMTruncateXlogRec(), WriteMZeroPageXlogRec(), WriteSetTimestampXlogRec(), WriteTruncateXlogRec(), WriteZeroPageXlogRec(), XactLogAbortRecord(), XactLogCommitRecord(), XLogPutNextOid(), XLogReportParameters(), XLogRestorePoint(), XLogSaveBufferForHint(), and xlogVacuumPage().

423 {
424  XLogRecPtr EndPos;
425 
426  /* XLogBeginInsert() must have been called. */
427  if (!begininsert_called)
428  elog(ERROR, "XLogBeginInsert was not called");
429 
430  /*
431  * The caller can set rmgr bits, XLR_SPECIAL_REL_UPDATE and
432  * XLR_CHECK_CONSISTENCY; the rest are reserved for use by me.
433  */
434  if ((info & ~(XLR_RMGR_INFO_MASK |
436  XLR_CHECK_CONSISTENCY)) != 0)
437  elog(PANIC, "invalid xlog info mask %02X", info);
438 
439  TRACE_POSTGRESQL_WAL_INSERT(rmid, info);
440 
441  /*
442  * In bootstrap mode, we don't actually log anything but XLOG resources;
443  * return a phony record pointer.
444  */
445  if (IsBootstrapProcessingMode() && rmid != RM_XLOG_ID)
446  {
448  EndPos = SizeOfXLogLongPHD; /* start of 1st chkpt record */
449  return EndPos;
450  }
451 
452  do
453  {
455  bool doPageWrites;
456  XLogRecPtr fpw_lsn;
457  XLogRecData *rdt;
458  int num_fpi = 0;
459 
460  /*
461  * Get values needed to decide whether to do full-page writes. Since
462  * we don't yet have an insertion lock, these could change under us,
463  * but XLogInsertRecord will recheck them once it has a lock.
464  */
465  GetFullPageWriteInfo(&RedoRecPtr, &doPageWrites);
466 
467  rdt = XLogRecordAssemble(rmid, info, RedoRecPtr, doPageWrites,
468  &fpw_lsn, &num_fpi);
469 
470  EndPos = XLogInsertRecord(rdt, fpw_lsn, curinsert_flags, num_fpi);
471  } while (EndPos == InvalidXLogRecPtr);
472 
474 
475  return EndPos;
476 }
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
#define XLR_SPECIAL_REL_UPDATE
Definition: xlogrecord.h:71
static bool begininsert_called
Definition: xloginsert.c:107
#define PANIC
Definition: elog.h:53
#define XLR_CHECK_CONSISTENCY
Definition: xlogrecord.h:80
static bool doPageWrites
Definition: xlog.c:381
#define ERROR
Definition: elog.h:43
void XLogResetInsertion(void)
Definition: xloginsert.c:196
static XLogRecData * XLogRecordAssemble(RmgrId rmid, uint8 info, XLogRecPtr RedoRecPtr, bool doPageWrites, XLogRecPtr *fpw_lsn, int *num_fpi)
Definition: xloginsert.c:491
static XLogRecPtr RedoRecPtr
Definition: xlog.c:374
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:393
void GetFullPageWriteInfo(XLogRecPtr *RedoRecPtr_p, bool *doPageWrites_p)
Definition: xlog.c:8392
#define elog(elevel,...)
Definition: elog.h:228
XLogRecPtr XLogInsertRecord(XLogRecData *rdata, XLogRecPtr fpw_lsn, uint8 flags, int num_fpi)
Definition: xlog.c:1000
static uint8 curinsert_flags
Definition: xloginsert.c:78
#define SizeOfXLogLongPHD
Definition: xlog_internal.h:69
#define XLR_RMGR_INFO_MASK
Definition: xlogrecord.h:63

◆ XLogRecordAssemble()

static XLogRecData * XLogRecordAssemble ( RmgrId  rmid,
uint8  info,
XLogRecPtr  RedoRecPtr,
bool  doPageWrites,
XLogRecPtr fpw_lsn,
int *  num_fpi 
)
static

Definition at line 491 of file xloginsert.c.

References XLogRecordBlockImageHeader::bimg_info, registered_buffer::bkp_rdatas, BKPBLOCK_HAS_DATA, BKPBLOCK_HAS_IMAGE, BKPBLOCK_SAME_REL, BKPBLOCK_WILL_INIT, BKPIMAGE_APPLY, BKPIMAGE_HAS_HOLE, BKPIMAGE_IS_COMPRESSED, registered_buffer::block, COMP_CRC32C, registered_buffer::compressed_page, curinsert_flags, XLogRecData::data, XLogRecordBlockHeader::data_length, registered_buffer::flags, XLogRecordBlockHeader::fork_flags, registered_buffer::forkno, GetCurrentTransactionIdIfAny(), GetTopTransactionIdIfAny(), hdr_rdt, hdr_scratch, XLogRecordBlockCompressHeader::hole_length, XLogRecordBlockImageHeader::hole_offset, XLogRecordBlockHeader::id, registered_buffer::in_use, INIT_CRC32C, InvalidRepOriginId, InvalidXLogRecPtr, IsSubTransactionAssignmentPending(), XLogRecData::len, XLogRecordBlockImageHeader::length, lower(), mainrdata_head, mainrdata_last, mainrdata_len, max_registered_block_id, XLogRecData::next, registered_buffer::page, PageGetLSN, registered_buffer::rdata_head, registered_buffer::rdata_len, registered_buffer::rdata_tail, RedoRecPtr, REGBUF_FORCE_IMAGE, REGBUF_KEEP_DATA, REGBUF_NO_IMAGE, REGBUF_STANDARD, REGBUF_WILL_INIT, RelFileNodeEquals, replorigin_session_origin, registered_buffer::rnode, SizeOfPageHeaderData, SizeOfXLogRecord, SizeOfXLogRecordBlockCompressHeader, SizeOfXLogRecordBlockHeader, SizeOfXLogRecordBlockImageHeader, upper(), wal_compression, wal_consistency_checking, XLogRecord::xl_crc, XLogRecord::xl_info, XLogRecord::xl_prev, XLogRecord::xl_rmid, XLogRecord::xl_tot_len, XLogRecord::xl_xid, XLOG_INCLUDE_ORIGIN, XLOG_INCLUDE_XID, XLogCompressBackupBlock(), XLogSetRecordFlags(), XLR_BLOCK_ID_DATA_LONG, XLR_BLOCK_ID_DATA_SHORT, XLR_BLOCK_ID_ORIGIN, XLR_BLOCK_ID_TOPLEVEL_XID, and XLR_CHECK_CONSISTENCY.

Referenced by XLogInsert().

494 {
495  XLogRecData *rdt;
496  uint32 total_len = 0;
497  int block_id;
498  pg_crc32c rdata_crc;
499  registered_buffer *prev_regbuf = NULL;
500  XLogRecData *rdt_datas_last;
501  XLogRecord *rechdr;
502  char *scratch = hdr_scratch;
503 
504  /*
505  * Note: this function can be called multiple times for the same record.
506  * All the modifications we do to the rdata chains below must handle that.
507  */
508 
509  /* The record begins with the fixed-size header */
510  rechdr = (XLogRecord *) scratch;
511  scratch += SizeOfXLogRecord;
512 
513  hdr_rdt.next = NULL;
514  rdt_datas_last = &hdr_rdt;
516 
517  /*
518  * Enforce consistency checks for this record if user is looking for it.
519  * Do this before at the beginning of this routine to give the possibility
520  * for callers of XLogInsert() to pass XLR_CHECK_CONSISTENCY directly for
521  * a record.
522  */
523  if (wal_consistency_checking[rmid])
524  info |= XLR_CHECK_CONSISTENCY;
525 
526  /*
527  * Make an rdata chain containing all the data portions of all block
528  * references. This includes the data for full-page images. Also append
529  * the headers for the block references in the scratch buffer.
530  */
531  *fpw_lsn = InvalidXLogRecPtr;
532  for (block_id = 0; block_id < max_registered_block_id; block_id++)
533  {
534  registered_buffer *regbuf = &registered_buffers[block_id];
535  bool needs_backup;
536  bool needs_data;
539  XLogRecordBlockCompressHeader cbimg = {0};
540  bool samerel;
541  bool is_compressed = false;
542  bool include_image;
543 
544  if (!regbuf->in_use)
545  continue;
546 
547  /* Determine if this block needs to be backed up */
548  if (regbuf->flags & REGBUF_FORCE_IMAGE)
549  needs_backup = true;
550  else if (regbuf->flags & REGBUF_NO_IMAGE)
551  needs_backup = false;
552  else if (!doPageWrites)
553  needs_backup = false;
554  else
555  {
556  /*
557  * We assume page LSN is first data on *every* page that can be
558  * passed to XLogInsert, whether it has the standard page layout
559  * or not.
560  */
561  XLogRecPtr page_lsn = PageGetLSN(regbuf->page);
562 
563  needs_backup = (page_lsn <= RedoRecPtr);
564  if (!needs_backup)
565  {
566  if (*fpw_lsn == InvalidXLogRecPtr || page_lsn < *fpw_lsn)
567  *fpw_lsn = page_lsn;
568  }
569  }
570 
571  /* Determine if the buffer data needs to included */
572  if (regbuf->rdata_len == 0)
573  needs_data = false;
574  else if ((regbuf->flags & REGBUF_KEEP_DATA) != 0)
575  needs_data = true;
576  else
577  needs_data = !needs_backup;
578 
579  bkpb.id = block_id;
580  bkpb.fork_flags = regbuf->forkno;
581  bkpb.data_length = 0;
582 
583  if ((regbuf->flags & REGBUF_WILL_INIT) == REGBUF_WILL_INIT)
585 
586  /*
587  * If needs_backup is true or WAL checking is enabled for current
588  * resource manager, log a full-page write for the current block.
589  */
590  include_image = needs_backup || (info & XLR_CHECK_CONSISTENCY) != 0;
591 
592  if (include_image)
593  {
594  Page page = regbuf->page;
595  uint16 compressed_len = 0;
596 
597  /*
598  * The page needs to be backed up, so calculate its hole length
599  * and offset.
600  */
601  if (regbuf->flags & REGBUF_STANDARD)
602  {
603  /* Assume we can omit data between pd_lower and pd_upper */
604  uint16 lower = ((PageHeader) page)->pd_lower;
605  uint16 upper = ((PageHeader) page)->pd_upper;
606 
607  if (lower >= SizeOfPageHeaderData &&
608  upper > lower &&
609  upper <= BLCKSZ)
610  {
611  bimg.hole_offset = lower;
612  cbimg.hole_length = upper - lower;
613  }
614  else
615  {
616  /* No "hole" to remove */
617  bimg.hole_offset = 0;
618  cbimg.hole_length = 0;
619  }
620  }
621  else
622  {
623  /* Not a standard page header, don't try to eliminate "hole" */
624  bimg.hole_offset = 0;
625  cbimg.hole_length = 0;
626  }
627 
628  /*
629  * Try to compress a block image if wal_compression is enabled
630  */
631  if (wal_compression)
632  {
633  is_compressed =
635  cbimg.hole_length,
636  regbuf->compressed_page,
637  &compressed_len);
638  }
639 
640  /*
641  * Fill in the remaining fields in the XLogRecordBlockHeader
642  * struct
643  */
645 
646  /* Report a full page image constructed for the WAL record */
647  *num_fpi += 1;
648 
649  /*
650  * Construct XLogRecData entries for the page content.
651  */
652  rdt_datas_last->next = &regbuf->bkp_rdatas[0];
653  rdt_datas_last = rdt_datas_last->next;
654 
655  bimg.bimg_info = (cbimg.hole_length == 0) ? 0 : BKPIMAGE_HAS_HOLE;
656 
657  /*
658  * If WAL consistency checking is enabled for the resource manager
659  * of this WAL record, a full-page image is included in the record
660  * for the block modified. During redo, the full-page is replayed
661  * only if BKPIMAGE_APPLY is set.
662  */
663  if (needs_backup)
664  bimg.bimg_info |= BKPIMAGE_APPLY;
665 
666  if (is_compressed)
667  {
668  bimg.length = compressed_len;
670 
671  rdt_datas_last->data = regbuf->compressed_page;
672  rdt_datas_last->len = compressed_len;
673  }
674  else
675  {
676  bimg.length = BLCKSZ - cbimg.hole_length;
677 
678  if (cbimg.hole_length == 0)
679  {
680  rdt_datas_last->data = page;
681  rdt_datas_last->len = BLCKSZ;
682  }
683  else
684  {
685  /* must skip the hole */
686  rdt_datas_last->data = page;
687  rdt_datas_last->len = bimg.hole_offset;
688 
689  rdt_datas_last->next = &regbuf->bkp_rdatas[1];
690  rdt_datas_last = rdt_datas_last->next;
691 
692  rdt_datas_last->data =
693  page + (bimg.hole_offset + cbimg.hole_length);
694  rdt_datas_last->len =
695  BLCKSZ - (bimg.hole_offset + cbimg.hole_length);
696  }
697  }
698 
699  total_len += bimg.length;
700  }
701 
702  if (needs_data)
703  {
704  /*
705  * Link the caller-supplied rdata chain for this buffer to the
706  * overall list.
707  */
709  bkpb.data_length = regbuf->rdata_len;
710  total_len += regbuf->rdata_len;
711 
712  rdt_datas_last->next = regbuf->rdata_head;
713  rdt_datas_last = regbuf->rdata_tail;
714  }
715 
716  if (prev_regbuf && RelFileNodeEquals(regbuf->rnode, prev_regbuf->rnode))
717  {
718  samerel = true;
720  }
721  else
722  samerel = false;
723  prev_regbuf = regbuf;
724 
725  /* Ok, copy the header to the scratch buffer */
726  memcpy(scratch, &bkpb, SizeOfXLogRecordBlockHeader);
727  scratch += SizeOfXLogRecordBlockHeader;
728  if (include_image)
729  {
730  memcpy(scratch, &bimg, SizeOfXLogRecordBlockImageHeader);
732  if (cbimg.hole_length != 0 && is_compressed)
733  {
734  memcpy(scratch, &cbimg,
737  }
738  }
739  if (!samerel)
740  {
741  memcpy(scratch, &regbuf->rnode, sizeof(RelFileNode));
742  scratch += sizeof(RelFileNode);
743  }
744  memcpy(scratch, &regbuf->block, sizeof(BlockNumber));
745  scratch += sizeof(BlockNumber);
746  }
747 
748  /* followed by the record's origin, if any */
751  {
752  *(scratch++) = (char) XLR_BLOCK_ID_ORIGIN;
753  memcpy(scratch, &replorigin_session_origin, sizeof(replorigin_session_origin));
754  scratch += sizeof(replorigin_session_origin);
755  }
756 
757  /* followed by toplevel XID, if not already included in previous record */
759  {
761 
762  /* update the flag (later used by XLogResetInsertion) */
764 
765  *(scratch++) = (char) XLR_BLOCK_ID_TOPLEVEL_XID;
766  memcpy(scratch, &xid, sizeof(TransactionId));
767  scratch += sizeof(TransactionId);
768  }
769 
770  /* followed by main data, if any */
771  if (mainrdata_len > 0)
772  {
773  if (mainrdata_len > 255)
774  {
775  *(scratch++) = (char) XLR_BLOCK_ID_DATA_LONG;
776  memcpy(scratch, &mainrdata_len, sizeof(uint32));
777  scratch += sizeof(uint32);
778  }
779  else
780  {
781  *(scratch++) = (char) XLR_BLOCK_ID_DATA_SHORT;
782  *(scratch++) = (uint8) mainrdata_len;
783  }
784  rdt_datas_last->next = mainrdata_head;
785  rdt_datas_last = mainrdata_last;
786  total_len += mainrdata_len;
787  }
788  rdt_datas_last->next = NULL;
789 
790  hdr_rdt.len = (scratch - hdr_scratch);
791  total_len += hdr_rdt.len;
792 
793  /*
794  * Calculate CRC of the data
795  *
796  * Note that the record header isn't added into the CRC initially since we
797  * don't know the prev-link yet. Thus, the CRC will represent the CRC of
798  * the whole record in the order: rdata, then backup blocks, then record
799  * header.
800  */
801  INIT_CRC32C(rdata_crc);
803  for (rdt = hdr_rdt.next; rdt != NULL; rdt = rdt->next)
804  COMP_CRC32C(rdata_crc, rdt->data, rdt->len);
805 
806  /*
807  * Fill in the fields in the record header. Prev-link is filled in later,
808  * once we know where in the WAL the record will be inserted. The CRC does
809  * not include the record header yet.
810  */
812  rechdr->xl_tot_len = total_len;
813  rechdr->xl_info = info;
814  rechdr->xl_rmid = rmid;
815  rechdr->xl_prev = InvalidXLogRecPtr;
816  rechdr->xl_crc = rdata_crc;
817 
818  return &hdr_rdt;
819 }
static XLogRecData hdr_rdt
Definition: xloginsert.c:88
#define INIT_CRC32C(crc)
Definition: pg_crc32c.h:41
XLogRecPtr xl_prev
Definition: xlogrecord.h:45
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
#define BKPIMAGE_HAS_HOLE
Definition: xlogrecord.h:146
static uint32 mainrdata_len
Definition: xloginsert.c:75
uint32 TransactionId
Definition: c.h:575
Datum lower(PG_FUNCTION_ARGS)
Definition: oracle_compat.c:44
#define XLR_BLOCK_ID_DATA_LONG
Definition: xlogrecord.h:224
uint32 pg_crc32c
Definition: pg_crc32c.h:38
BlockNumber block
Definition: xloginsert.c:49
unsigned char uint8
Definition: c.h:427
#define REGBUF_WILL_INIT
Definition: xloginsert.h:33
RmgrId xl_rmid
Definition: xlogrecord.h:47
#define XLOG_INCLUDE_ORIGIN
Definition: xlog.h:238
uint32 BlockNumber
Definition: block.h:31
Datum upper(PG_FUNCTION_ARGS)
Definition: oracle_compat.c:75
XLogRecData * rdata_head
Definition: xloginsert.c:52
#define SizeOfPageHeaderData
Definition: bufpage.h:216
#define XLR_CHECK_CONSISTENCY
Definition: xlogrecord.h:80
RelFileNode rnode
Definition: xloginsert.c:47
unsigned short uint16
Definition: c.h:428
static bool doPageWrites
Definition: xlog.c:381
#define XLR_BLOCK_ID_TOPLEVEL_XID
Definition: xlogrecord.h:226
uint32 xl_tot_len
Definition: xlogrecord.h:43
#define SizeOfXLogRecordBlockImageHeader
Definition: xlogrecord.h:142
static XLogRecPtr RedoRecPtr
Definition: xlog.c:374
#define BKPIMAGE_APPLY
Definition: xlogrecord.h:148
struct RelFileNode RelFileNode
static XLogRecData * mainrdata_head
Definition: xloginsert.c:73
#define REGBUF_STANDARD
Definition: xloginsert.h:35
TransactionId GetCurrentTransactionIdIfAny(void)
Definition: xact.c:455
unsigned int uint32
Definition: c.h:429
TransactionId GetTopTransactionIdIfAny(void)
Definition: xact.c:425
void XLogSetRecordFlags(uint8 flags)
Definition: xloginsert.c:404
#define BKPBLOCK_WILL_INIT
Definition: xlogrecord.h:182
XLogRecData * rdata_tail
Definition: xloginsert.c:54
static registered_buffer * registered_buffers
Definition: xloginsert.c:64
#define SizeOfXLogRecord
Definition: xlogrecord.h:55
#define REGBUF_FORCE_IMAGE
Definition: xloginsert.h:31
#define BKPBLOCK_SAME_REL
Definition: xlogrecord.h:183
#define BKPIMAGE_IS_COMPRESSED
Definition: xlogrecord.h:147
#define REGBUF_KEEP_DATA
Definition: xloginsert.h:38
#define BKPBLOCK_HAS_IMAGE
Definition: xlogrecord.h:180
bool IsSubTransactionAssignmentPending(void)
Definition: xact.c:6079
#define XLOG_INCLUDE_XID
Definition: xlog.h:240
static XLogRecData * mainrdata_last
Definition: xloginsert.c:74
PageHeaderData * PageHeader
Definition: bufpage.h:166
uint64 XLogRecPtr
Definition: xlogdefs.h:21
RepOriginId replorigin_session_origin
Definition: origin.c:154
bool * wal_consistency_checking
Definition: xlog.c:102
uint8 xl_info
Definition: xlogrecord.h:46
#define REGBUF_NO_IMAGE
Definition: xloginsert.h:32
#define XLR_BLOCK_ID_ORIGIN
Definition: xlogrecord.h:225
ForkNumber forkno
Definition: xloginsert.c:48
pg_crc32c xl_crc
Definition: xlogrecord.h:49
struct XLogRecData * next
#define InvalidRepOriginId
Definition: origin.h:33
#define PageGetLSN(page)
Definition: bufpage.h:366
#define XLR_BLOCK_ID_DATA_SHORT
Definition: xlogrecord.h:223
static char * hdr_scratch
Definition: xloginsert.c:89
TransactionId xl_xid
Definition: xlogrecord.h:44
static int max_registered_block_id
Definition: xloginsert.c:66
char compressed_page[PGLZ_MAX_BLCKSZ]
Definition: xloginsert.c:61
bool wal_compression
Definition: xlog.c:100
static bool XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, char *dest, uint16 *dlen)
Definition: xloginsert.c:829
static uint8 curinsert_flags
Definition: xloginsert.c:78
XLogRecData bkp_rdatas[2]
Definition: xloginsert.c:57
#define COMP_CRC32C(crc, data, len)
Definition: pg_crc32c.h:89
#define SizeOfXLogRecordBlockCompressHeader
Definition: xlogrecord.h:160
Pointer Page
Definition: bufpage.h:78
#define RelFileNodeEquals(node1, node2)
Definition: relfilenode.h:88
#define BKPBLOCK_HAS_DATA
Definition: xlogrecord.h:181
#define SizeOfXLogRecordBlockHeader
Definition: xlogrecord.h:104

◆ XLogRegisterBlock()

void XLogRegisterBlock ( uint8  block_id,
RelFileNode rnode,
ForkNumber  forknum,
BlockNumber  blknum,
Page  page,
uint8  flags 
)

Definition at line 273 of file xloginsert.c.

References Assert, begininsert_called, registered_buffer::block, elog, ERROR, registered_buffer::flags, registered_buffer::forkno, i, registered_buffer::in_use, max_registered_block_id, max_registered_buffers, registered_buffer::page, registered_buffer::rdata_head, registered_buffer::rdata_len, registered_buffer::rdata_tail, REGBUF_FORCE_IMAGE, RelFileNodeEquals, and registered_buffer::rnode.

Referenced by log_newpage(), log_newpages(), and XLogSaveBufferForHint().

275 {
276  registered_buffer *regbuf;
277 
278  /* This is currently only used to WAL-log a full-page image of a page */
279  Assert(flags & REGBUF_FORCE_IMAGE);
281 
282  if (block_id >= max_registered_block_id)
283  max_registered_block_id = block_id + 1;
284 
285  if (block_id >= max_registered_buffers)
286  elog(ERROR, "too many registered buffers");
287 
288  regbuf = &registered_buffers[block_id];
289 
290  regbuf->rnode = *rnode;
291  regbuf->forkno = forknum;
292  regbuf->block = blknum;
293  regbuf->page = page;
294  regbuf->flags = flags;
295  regbuf->rdata_tail = (XLogRecData *) &regbuf->rdata_head;
296  regbuf->rdata_len = 0;
297 
298  /*
299  * Check that this page hasn't already been registered with some other
300  * block_id.
301  */
302 #ifdef USE_ASSERT_CHECKING
303  {
304  int i;
305 
306  for (i = 0; i < max_registered_block_id; i++)
307  {
308  registered_buffer *regbuf_old = &registered_buffers[i];
309 
310  if (i == block_id || !regbuf_old->in_use)
311  continue;
312 
313  Assert(!RelFileNodeEquals(regbuf_old->rnode, regbuf->rnode) ||
314  regbuf_old->forkno != regbuf->forkno ||
315  regbuf_old->block != regbuf->block);
316  }
317  }
318 #endif
319 
320  regbuf->in_use = true;
321 }
BlockNumber block
Definition: xloginsert.c:49
static bool begininsert_called
Definition: xloginsert.c:107
XLogRecData * rdata_head
Definition: xloginsert.c:52
RelFileNode rnode
Definition: xloginsert.c:47
#define ERROR
Definition: elog.h:43
static int max_registered_buffers
Definition: xloginsert.c:65
XLogRecData * rdata_tail
Definition: xloginsert.c:54
static registered_buffer * registered_buffers
Definition: xloginsert.c:64
#define REGBUF_FORCE_IMAGE
Definition: xloginsert.h:31
#define Assert(condition)
Definition: c.h:800
ForkNumber forkno
Definition: xloginsert.c:48
static int max_registered_block_id
Definition: xloginsert.c:66
#define elog(elevel,...)
Definition: elog.h:228
int i
#define RelFileNodeEquals(node1, node2)
Definition: relfilenode.h:88

◆ XLogRegisterBufData()

void XLogRegisterBufData ( uint8  block_id,
char *  data,
int  len 
)

Definition at line 368 of file xloginsert.c.

References Assert, begininsert_called, XLogRecData::data, elog, ERROR, registered_buffer::in_use, XLogRecData::len, max_rdatas, XLogRecData::next, num_rdatas, registered_buffer::rdata_len, and registered_buffer::rdata_tail.

Referenced by _bt_dedup_pass(), _bt_delitems_delete(), _bt_delitems_vacuum(), _bt_getroot(), _bt_insertonpg(), _bt_newroot(), _bt_split(), _bt_unlink_halfdead_page(), _bt_update_meta_cleanup_info(), _hash_addovflpage(), _hash_doinsert(), _hash_expandtable(), _hash_freeovflpage(), _hash_squeezebucket(), brin_doinsert(), brin_doupdate(), dataExecPlaceToPageInternal(), dataExecPlaceToPageLeaf(), entryExecPlaceToPage(), GenericXLogFinish(), ginHeapTupleFastInsert(), ginVacuumPostingTreeLeaf(), gistXLogSplit(), gistXLogUpdate(), hashbucketcleanup(), heap_inplace_update(), heap_insert(), heap_multi_insert(), log_heap_clean(), log_heap_freeze(), log_heap_update(), and writeListPage().

369 {
370  registered_buffer *regbuf;
371  XLogRecData *rdata;
372 
374 
375  /* find the registered buffer struct */
376  regbuf = &registered_buffers[block_id];
377  if (!regbuf->in_use)
378  elog(ERROR, "no block with id %d registered with WAL insertion",
379  block_id);
380 
381  if (num_rdatas >= max_rdatas)
382  elog(ERROR, "too much WAL data");
383  rdata = &rdatas[num_rdatas++];
384 
385  rdata->data = data;
386  rdata->len = len;
387 
388  regbuf->rdata_tail->next = rdata;
389  regbuf->rdata_tail = rdata;
390  regbuf->rdata_len += len;
391 }
static bool begininsert_called
Definition: xloginsert.c:107
#define ERROR
Definition: elog.h:43
XLogRecData * rdata_tail
Definition: xloginsert.c:54
static int max_rdatas
Definition: xloginsert.c:105
static registered_buffer * registered_buffers
Definition: xloginsert.c:64
static int num_rdatas
Definition: xloginsert.c:104
#define Assert(condition)
Definition: c.h:800
struct XLogRecData * next
#define elog(elevel,...)
Definition: elog.h:228
static XLogRecData * rdatas
Definition: xloginsert.c:103

◆ XLogRegisterBuffer()

void XLogRegisterBuffer ( uint8  block_id,
Buffer  buffer,
uint8  flags 
)

Definition at line 220 of file xloginsert.c.

References Assert, begininsert_called, registered_buffer::block, BufferGetPage, BufferGetTag(), elog, ERROR, registered_buffer::flags, registered_buffer::forkno, i, registered_buffer::in_use, max_registered_block_id, max_registered_buffers, registered_buffer::page, registered_buffer::rdata_head, registered_buffer::rdata_len, registered_buffer::rdata_tail, REGBUF_FORCE_IMAGE, REGBUF_NO_IMAGE, RelFileNodeEquals, and registered_buffer::rnode.

Referenced by _bt_dedup_pass(), _bt_delitems_delete(), _bt_delitems_vacuum(), _bt_getroot(), _bt_insertonpg(), _bt_mark_page_halfdead(), _bt_newroot(), _bt_split(), _bt_unlink_halfdead_page(), _bt_update_meta_cleanup_info(), _hash_addovflpage(), _hash_doinsert(), _hash_expandtable(), _hash_freeovflpage(), _hash_init(), _hash_splitbucket(), _hash_squeezebucket(), _hash_vacuum_one_page(), addLeafTuple(), brin_doinsert(), brin_doupdate(), brinbuild(), brinRevmapDesummarizeRange(), createPostingTree(), do_setval(), doPickSplit(), fill_seq_with_data(), GenericXLogFinish(), ginDeletePage(), ginHeapTupleFastInsert(), ginPlaceToPage(), ginUpdateStats(), ginVacuumPostingTreeLeaf(), gistXLogDelete(), gistXLogPageDelete(), gistXLogSplit(), gistXLogUpdate(), hashbucketcleanup(), hashbulkdelete(), heap_abort_speculative(), heap_delete(), heap_finish_speculative(), heap_inplace_update(), heap_insert(), heap_lock_tuple(), heap_lock_updated_tuple_rec(), heap_multi_insert(), heap_update(), log_heap_clean(), log_heap_freeze(), log_heap_update(), log_heap_visible(), log_newpage_range(), log_split_page(), moveLeafs(), nextval_internal(), revmap_physical_extend(), shiftList(), spgAddNodeAction(), spgSplitNodeAction(), vacuumLeafPage(), vacuumLeafRoot(), vacuumRedirectAndPlaceholder(), writeListPage(), and xlogVacuumPage().

221 {
222  registered_buffer *regbuf;
223 
224  /* NO_IMAGE doesn't make sense with FORCE_IMAGE */
225  Assert(!((flags & REGBUF_FORCE_IMAGE) && (flags & (REGBUF_NO_IMAGE))));
227 
228  if (block_id >= max_registered_block_id)
229  {
230  if (block_id >= max_registered_buffers)
231  elog(ERROR, "too many registered buffers");
232  max_registered_block_id = block_id + 1;
233  }
234 
235  regbuf = &registered_buffers[block_id];
236 
237  BufferGetTag(buffer, &regbuf->rnode, &regbuf->forkno, &regbuf->block);
238  regbuf->page = BufferGetPage(buffer);
239  regbuf->flags = flags;
240  regbuf->rdata_tail = (XLogRecData *) &regbuf->rdata_head;
241  regbuf->rdata_len = 0;
242 
243  /*
244  * Check that this page hasn't already been registered with some other
245  * block_id.
246  */
247 #ifdef USE_ASSERT_CHECKING
248  {
249  int i;
250 
251  for (i = 0; i < max_registered_block_id; i++)
252  {
253  registered_buffer *regbuf_old = &registered_buffers[i];
254 
255  if (i == block_id || !regbuf_old->in_use)
256  continue;
257 
258  Assert(!RelFileNodeEquals(regbuf_old->rnode, regbuf->rnode) ||
259  regbuf_old->forkno != regbuf->forkno ||
260  regbuf_old->block != regbuf->block);
261  }
262  }
263 #endif
264 
265  regbuf->in_use = true;
266 }
BlockNumber block
Definition: xloginsert.c:49
static bool begininsert_called
Definition: xloginsert.c:107
XLogRecData * rdata_head
Definition: xloginsert.c:52
RelFileNode rnode
Definition: xloginsert.c:47
#define ERROR
Definition: elog.h:43
static int max_registered_buffers
Definition: xloginsert.c:65
#define BufferGetPage(buffer)
Definition: bufmgr.h:169
XLogRecData * rdata_tail
Definition: xloginsert.c:54
static registered_buffer * registered_buffers
Definition: xloginsert.c:64
#define REGBUF_FORCE_IMAGE
Definition: xloginsert.h:31
#define Assert(condition)
Definition: c.h:800
#define REGBUF_NO_IMAGE
Definition: xloginsert.h:32
ForkNumber forkno
Definition: xloginsert.c:48
static int max_registered_block_id
Definition: xloginsert.c:66
#define elog(elevel,...)
Definition: elog.h:228
int i
void BufferGetTag(Buffer buffer, RelFileNode *rnode, ForkNumber *forknum, BlockNumber *blknum)
Definition: bufmgr.c:2684
#define RelFileNodeEquals(node1, node2)
Definition: relfilenode.h:88

◆ XLogRegisterData()

void XLogRegisterData ( char *  data,
int  len 
)

Definition at line 330 of file xloginsert.c.

References Assert, begininsert_called, XLogRecData::data, elog, ERROR, XLogRecData::len, mainrdata_len, max_rdatas, XLogRecData::next, and num_rdatas.

Referenced by _bt_dedup_pass(), _bt_delitems_delete(), _bt_delitems_vacuum(), _bt_getroot(), _bt_insertonpg(), _bt_log_reuse_page(), _bt_mark_page_halfdead(), _bt_newroot(), _bt_split(), _bt_unlink_halfdead_page(), _hash_addovflpage(), _hash_doinsert(), _hash_expandtable(), _hash_freeovflpage(), _hash_init(), _hash_splitbucket(), _hash_squeezebucket(), _hash_vacuum_one_page(), addLeafTuple(), AssignTransactionId(), brin_doinsert(), brin_doupdate(), brinbuild(), brinRevmapDesummarizeRange(), CreateCheckPoint(), createdb(), CreateEndOfRecoveryRecord(), createPostingTree(), CreateTableSpace(), do_pg_stop_backup(), do_setval(), doPickSplit(), DropTableSpace(), EndPrepare(), ExecuteTruncateGuts(), fill_seq_with_data(), ginDeletePage(), ginHeapTupleFastInsert(), ginPlaceToPage(), ginUpdateStats(), gistXLogAssignLSN(), gistXLogDelete(), gistXLogPageDelete(), gistXLogPageReuse(), gistXLogSplit(), gistXLogUpdate(), hashbucketcleanup(), hashbulkdelete(), heap_abort_speculative(), heap_delete(), heap_finish_speculative(), heap_inplace_update(), heap_insert(), heap_lock_tuple(), heap_lock_updated_tuple_rec(), heap_multi_insert(), heap_update(), log_heap_clean(), log_heap_cleanup_info(), log_heap_freeze(), log_heap_new_cid(), log_heap_update(), log_heap_visible(), log_smgrcreate(), LogAccessExclusiveLocks(), LogCurrentRunningXacts(), logical_heap_rewrite_flush_mappings(), LogLogicalInvalidations(), LogLogicalMessage(), LogStandbyInvalidations(), movedb(), moveLeafs(), MultiXactIdCreateFromMembers(), nextval_internal(), pg_truncate_visibility_map(), RelationTruncate(), remove_dbtablespaces(), replorigin_advance(), replorigin_drop(), revmap_physical_extend(), shiftList(), spgAddNodeAction(), spgSplitNodeAction(), UpdateFullPageWrites(), vacuumLeafPage(), vacuumLeafRoot(), vacuumRedirectAndPlaceholder(), write_relmap_file(), writeListPage(), WriteMTruncateXlogRec(), WriteMZeroPageXlogRec(), WriteSetTimestampXlogRec(), WriteTruncateXlogRec(), WriteZeroPageXlogRec(), XactLogAbortRecord(), XactLogCommitRecord(), XLogPutNextOid(), XLogReportParameters(), and XLogRestorePoint().

331 {
332  XLogRecData *rdata;
333 
335 
336  if (num_rdatas >= max_rdatas)
337  elog(ERROR, "too much WAL data");
338  rdata = &rdatas[num_rdatas++];
339 
340  rdata->data = data;
341  rdata->len = len;
342 
343  /*
344  * we use the mainrdata_last pointer to track the end of the chain, so no
345  * need to clear 'next' here.
346  */
347 
348  mainrdata_last->next = rdata;
349  mainrdata_last = rdata;
350 
351  mainrdata_len += len;
352 }
static uint32 mainrdata_len
Definition: xloginsert.c:75
static bool begininsert_called
Definition: xloginsert.c:107
#define ERROR
Definition: elog.h:43
static int max_rdatas
Definition: xloginsert.c:105
static XLogRecData * mainrdata_last
Definition: xloginsert.c:74
static int num_rdatas
Definition: xloginsert.c:104
#define Assert(condition)
Definition: c.h:800
struct XLogRecData * next
#define elog(elevel,...)
Definition: elog.h:228
static XLogRecData * rdatas
Definition: xloginsert.c:103

◆ XLogResetInsertion()

void XLogResetInsertion ( void  )

Definition at line 196 of file xloginsert.c.

References begininsert_called, curinsert_flags, i, mainrdata_len, MarkSubTransactionAssigned(), max_registered_block_id, num_rdatas, and XLOG_INCLUDE_XID.

Referenced by AbortSubTransaction(), AbortTransaction(), and XLogInsert().

197 {
198  int i;
199 
200  /* reset the subxact assignment flag (if needed) */
203 
204  for (i = 0; i < max_registered_block_id; i++)
205  registered_buffers[i].in_use = false;
206 
207  num_rdatas = 0;
208  max_registered_block_id = 0;
209  mainrdata_len = 0;
211  curinsert_flags = 0;
212  begininsert_called = false;
213 }
void MarkSubTransactionAssigned(void)
Definition: xact.c:6107
static uint32 mainrdata_len
Definition: xloginsert.c:75
static bool begininsert_called
Definition: xloginsert.c:107
static XLogRecData * mainrdata_head
Definition: xloginsert.c:73
static registered_buffer * registered_buffers
Definition: xloginsert.c:64
#define XLOG_INCLUDE_XID
Definition: xlog.h:240
static XLogRecData * mainrdata_last
Definition: xloginsert.c:74
static int num_rdatas
Definition: xloginsert.c:104
static int max_registered_block_id
Definition: xloginsert.c:66
int i
static uint8 curinsert_flags
Definition: xloginsert.c:78

◆ XLogSaveBufferForHint()

XLogRecPtr XLogSaveBufferForHint ( Buffer  buffer,
bool  buffer_std 
)

Definition at line 917 of file xloginsert.c.

References Assert, BufferGetBlock, BufferGetLSNAtomic(), BufferGetPage, BufferGetTag(), PGAlignedBlock::data, PGPROC::delayChkpt, GetRedoRecPtr(), InvalidXLogRecPtr, lower(), MyProc, RedoRecPtr, REGBUF_FORCE_IMAGE, REGBUF_STANDARD, upper(), XLOG_FPI_FOR_HINT, XLogBeginInsert(), XLogInsert(), and XLogRegisterBlock().

Referenced by MarkBufferDirtyHint().

918 {
919  XLogRecPtr recptr = InvalidXLogRecPtr;
920  XLogRecPtr lsn;
922 
923  /*
924  * Ensure no checkpoint can change our view of RedoRecPtr.
925  */
927 
928  /*
929  * Update RedoRecPtr so that we can make the right decision
930  */
931  RedoRecPtr = GetRedoRecPtr();
932 
933  /*
934  * We assume page LSN is first data on *every* page that can be passed to
935  * XLogInsert, whether it has the standard page layout or not. Since we're
936  * only holding a share-lock on the page, we must take the buffer header
937  * lock when we look at the LSN.
938  */
939  lsn = BufferGetLSNAtomic(buffer);
940 
941  if (lsn <= RedoRecPtr)
942  {
943  int flags;
944  PGAlignedBlock copied_buffer;
945  char *origdata = (char *) BufferGetBlock(buffer);
946  RelFileNode rnode;
947  ForkNumber forkno;
948  BlockNumber blkno;
949 
950  /*
951  * Copy buffer so we don't have to worry about concurrent hint bit or
952  * lsn updates. We assume pd_lower/upper cannot be changed without an
953  * exclusive lock, so the contents bkp are not racy.
954  */
955  if (buffer_std)
956  {
957  /* Assume we can omit data between pd_lower and pd_upper */
958  Page page = BufferGetPage(buffer);
959  uint16 lower = ((PageHeader) page)->pd_lower;
960  uint16 upper = ((PageHeader) page)->pd_upper;
961 
962  memcpy(copied_buffer.data, origdata, lower);
963  memcpy(copied_buffer.data + upper, origdata + upper, BLCKSZ - upper);
964  }
965  else
966  memcpy(copied_buffer.data, origdata, BLCKSZ);
967 
968  XLogBeginInsert();
969 
970  flags = REGBUF_FORCE_IMAGE;
971  if (buffer_std)
972  flags |= REGBUF_STANDARD;
973 
974  BufferGetTag(buffer, &rnode, &forkno, &blkno);
975  XLogRegisterBlock(0, &rnode, forkno, blkno, copied_buffer.data, flags);
976 
977  recptr = XLogInsert(RM_XLOG_ID, XLOG_FPI_FOR_HINT);
978  }
979 
980  return recptr;
981 }
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
Datum lower(PG_FUNCTION_ARGS)
Definition: oracle_compat.c:44
PGPROC * MyProc
Definition: proc.c:67
uint32 BlockNumber
Definition: block.h:31
Datum upper(PG_FUNCTION_ARGS)
Definition: oracle_compat.c:75
char data[BLCKSZ]
Definition: c.h:1137
void XLogRegisterBlock(uint8 block_id, RelFileNode *rnode, ForkNumber forknum, BlockNumber blknum, Page page, uint8 flags)
Definition: xloginsert.c:273
unsigned short uint16
Definition: c.h:428
bool delayChkpt
Definition: proc.h:184
static XLogRecPtr RedoRecPtr
Definition: xlog.c:374
XLogRecPtr BufferGetLSNAtomic(Buffer buffer)
Definition: bufmgr.c:2926
#define REGBUF_STANDARD
Definition: xloginsert.h:35
#define BufferGetPage(buffer)
Definition: bufmgr.h:169
ForkNumber
Definition: relpath.h:40
#define REGBUF_FORCE_IMAGE
Definition: xloginsert.h:31
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:422
PageHeaderData * PageHeader
Definition: bufpage.h:166
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:800
#define XLOG_FPI_FOR_HINT
Definition: pg_control.h:77
XLogRecPtr GetRedoRecPtr(void)
Definition: xlog.c:8363
void BufferGetTag(Buffer buffer, RelFileNode *rnode, ForkNumber *forknum, BlockNumber *blknum)
Definition: bufmgr.c:2684
void XLogBeginInsert(void)
Definition: xloginsert.c:123
#define BufferGetBlock(buffer)
Definition: bufmgr.h:136
Pointer Page
Definition: bufpage.h:78

◆ XLogSetRecordFlags()

Variable Documentation

◆ begininsert_called

◆ curinsert_flags

uint8 curinsert_flags = 0
static

◆ hdr_rdt

XLogRecData hdr_rdt
static

Definition at line 88 of file xloginsert.c.

Referenced by XLogRecordAssemble().

◆ hdr_scratch

char* hdr_scratch = NULL
static

Definition at line 89 of file xloginsert.c.

Referenced by InitXLogInsert(), and XLogRecordAssemble().

◆ mainrdata_head

XLogRecData* mainrdata_head
static

Definition at line 73 of file xloginsert.c.

Referenced by XLogRecordAssemble().

◆ mainrdata_last

XLogRecData* mainrdata_last = (XLogRecData *) &mainrdata_head
static

Definition at line 74 of file xloginsert.c.

Referenced by XLogRecordAssemble().

◆ mainrdata_len

uint32 mainrdata_len
static

◆ max_rdatas

int max_rdatas
static

◆ max_registered_block_id

int max_registered_block_id = 0
static

◆ max_registered_buffers

int max_registered_buffers
static

◆ num_rdatas

int num_rdatas
static

Definition at line 104 of file xloginsert.c.

Referenced by XLogRegisterBufData(), XLogRegisterData(), and XLogResetInsertion().

◆ rdatas

XLogRecData* rdatas
static

Definition at line 103 of file xloginsert.c.

◆ registered_buffers

registered_buffer* registered_buffers
static

Definition at line 64 of file xloginsert.c.

◆ xloginsert_cxt

MemoryContext xloginsert_cxt
static

Definition at line 110 of file xloginsert.c.