PostgreSQL Source Code  git master
heapam_xlog.h File Reference
#include "access/htup.h"
#include "access/xlogreader.h"
#include "lib/stringinfo.h"
#include "storage/buf.h"
#include "storage/bufpage.h"
#include "storage/relfilelocator.h"
#include "utils/relcache.h"
Include dependency graph for heapam_xlog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  xl_heap_delete
 
struct  xl_heap_truncate
 
struct  xl_heap_header
 
struct  xl_heap_insert
 
struct  xl_heap_multi_insert
 
struct  xl_multi_insert_tuple
 
struct  xl_heap_update
 
struct  xl_heap_prune
 
struct  xl_heap_vacuum
 
struct  xl_heap_lock
 
struct  xl_heap_lock_updated
 
struct  xl_heap_confirm
 
struct  xl_heap_inplace
 
struct  xl_heap_freeze_plan
 
struct  xl_heap_freeze_page
 
struct  xl_heap_visible
 
struct  xl_heap_new_cid
 
struct  xl_heap_rewrite_mapping
 

Macros

#define XLOG_HEAP_INSERT   0x00
 
#define XLOG_HEAP_DELETE   0x10
 
#define XLOG_HEAP_UPDATE   0x20
 
#define XLOG_HEAP_TRUNCATE   0x30
 
#define XLOG_HEAP_HOT_UPDATE   0x40
 
#define XLOG_HEAP_CONFIRM   0x50
 
#define XLOG_HEAP_LOCK   0x60
 
#define XLOG_HEAP_INPLACE   0x70
 
#define XLOG_HEAP_OPMASK   0x70
 
#define XLOG_HEAP_INIT_PAGE   0x80
 
#define XLOG_HEAP2_REWRITE   0x00
 
#define XLOG_HEAP2_PRUNE   0x10
 
#define XLOG_HEAP2_VACUUM   0x20
 
#define XLOG_HEAP2_FREEZE_PAGE   0x30
 
#define XLOG_HEAP2_VISIBLE   0x40
 
#define XLOG_HEAP2_MULTI_INSERT   0x50
 
#define XLOG_HEAP2_LOCK_UPDATED   0x60
 
#define XLOG_HEAP2_NEW_CID   0x70
 
#define XLH_INSERT_ALL_VISIBLE_CLEARED   (1<<0)
 
#define XLH_INSERT_LAST_IN_MULTI   (1<<1)
 
#define XLH_INSERT_IS_SPECULATIVE   (1<<2)
 
#define XLH_INSERT_CONTAINS_NEW_TUPLE   (1<<3)
 
#define XLH_INSERT_ON_TOAST_RELATION   (1<<4)
 
#define XLH_INSERT_ALL_FROZEN_SET   (1<<5)
 
#define XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED   (1<<0)
 
#define XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED   (1<<1)
 
#define XLH_UPDATE_CONTAINS_OLD_TUPLE   (1<<2)
 
#define XLH_UPDATE_CONTAINS_OLD_KEY   (1<<3)
 
#define XLH_UPDATE_CONTAINS_NEW_TUPLE   (1<<4)
 
#define XLH_UPDATE_PREFIX_FROM_OLD   (1<<5)
 
#define XLH_UPDATE_SUFFIX_FROM_OLD   (1<<6)
 
#define XLH_UPDATE_CONTAINS_OLD    (XLH_UPDATE_CONTAINS_OLD_TUPLE | XLH_UPDATE_CONTAINS_OLD_KEY)
 
#define XLH_DELETE_ALL_VISIBLE_CLEARED   (1<<0)
 
#define XLH_DELETE_CONTAINS_OLD_TUPLE   (1<<1)
 
#define XLH_DELETE_CONTAINS_OLD_KEY   (1<<2)
 
#define XLH_DELETE_IS_SUPER   (1<<3)
 
#define XLH_DELETE_IS_PARTITION_MOVE   (1<<4)
 
#define XLH_DELETE_CONTAINS_OLD    (XLH_DELETE_CONTAINS_OLD_TUPLE | XLH_DELETE_CONTAINS_OLD_KEY)
 
#define SizeOfHeapDelete   (offsetof(xl_heap_delete, flags) + sizeof(uint8))
 
#define XLH_TRUNCATE_CASCADE   (1<<0)
 
#define XLH_TRUNCATE_RESTART_SEQS   (1<<1)
 
#define SizeOfHeapTruncate   (offsetof(xl_heap_truncate, relids))
 
#define SizeOfHeapHeader   (offsetof(xl_heap_header, t_hoff) + sizeof(uint8))
 
#define SizeOfHeapInsert   (offsetof(xl_heap_insert, flags) + sizeof(uint8))
 
#define SizeOfHeapMultiInsert   offsetof(xl_heap_multi_insert, offsets)
 
#define SizeOfMultiInsertTuple   (offsetof(xl_multi_insert_tuple, t_hoff) + sizeof(uint8))
 
#define SizeOfHeapUpdate   (offsetof(xl_heap_update, new_offnum) + sizeof(OffsetNumber))
 
#define SizeOfHeapPrune   (offsetof(xl_heap_prune, isCatalogRel) + sizeof(bool))
 
#define SizeOfHeapVacuum   (offsetof(xl_heap_vacuum, nunused) + sizeof(uint16))
 
#define XLHL_XMAX_IS_MULTI   0x01
 
#define XLHL_XMAX_LOCK_ONLY   0x02
 
#define XLHL_XMAX_EXCL_LOCK   0x04
 
#define XLHL_XMAX_KEYSHR_LOCK   0x08
 
#define XLHL_KEYS_UPDATED   0x10
 
#define XLH_LOCK_ALL_FROZEN_CLEARED   0x01
 
#define SizeOfHeapLock   (offsetof(xl_heap_lock, flags) + sizeof(uint8))
 
#define SizeOfHeapLockUpdated   (offsetof(xl_heap_lock_updated, flags) + sizeof(uint8))
 
#define SizeOfHeapConfirm   (offsetof(xl_heap_confirm, offnum) + sizeof(OffsetNumber))
 
#define SizeOfHeapInplace   (offsetof(xl_heap_inplace, offnum) + sizeof(OffsetNumber))
 
#define XLH_FREEZE_XVAC   0x02
 
#define XLH_INVALID_XVAC   0x04
 
#define SizeOfHeapFreezePage   (offsetof(xl_heap_freeze_page, isCatalogRel) + sizeof(bool))
 
#define SizeOfHeapVisible   (offsetof(xl_heap_visible, flags) + sizeof(uint8))
 
#define SizeOfHeapNewCid   (offsetof(xl_heap_new_cid, target_tid) + sizeof(ItemPointerData))
 

Typedefs

typedef struct xl_heap_delete xl_heap_delete
 
typedef struct xl_heap_truncate xl_heap_truncate
 
typedef struct xl_heap_header xl_heap_header
 
typedef struct xl_heap_insert xl_heap_insert
 
typedef struct xl_heap_multi_insert xl_heap_multi_insert
 
typedef struct xl_multi_insert_tuple xl_multi_insert_tuple
 
typedef struct xl_heap_update xl_heap_update
 
typedef struct xl_heap_prune xl_heap_prune
 
typedef struct xl_heap_vacuum xl_heap_vacuum
 
typedef struct xl_heap_lock xl_heap_lock
 
typedef struct xl_heap_lock_updated xl_heap_lock_updated
 
typedef struct xl_heap_confirm xl_heap_confirm
 
typedef struct xl_heap_inplace xl_heap_inplace
 
typedef struct xl_heap_freeze_plan xl_heap_freeze_plan
 
typedef struct xl_heap_freeze_page xl_heap_freeze_page
 
typedef struct xl_heap_visible xl_heap_visible
 
typedef struct xl_heap_new_cid xl_heap_new_cid
 
typedef struct xl_heap_rewrite_mapping xl_heap_rewrite_mapping
 

Functions

void HeapTupleHeaderAdvanceConflictHorizon (HeapTupleHeader tuple, TransactionId *snapshotConflictHorizon)
 
void heap_redo (XLogReaderState *record)
 
void heap_desc (StringInfo buf, XLogReaderState *record)
 
const char * heap_identify (uint8 info)
 
void heap_mask (char *pagedata, BlockNumber blkno)
 
void heap2_redo (XLogReaderState *record)
 
void heap2_desc (StringInfo buf, XLogReaderState *record)
 
const char * heap2_identify (uint8 info)
 
void heap_xlog_logical_rewrite (XLogReaderState *r)
 
XLogRecPtr log_heap_visible (Relation rel, Buffer heap_buffer, Buffer vm_buffer, TransactionId snapshotConflictHorizon, uint8 vmflags)
 

Macro Definition Documentation

◆ SizeOfHeapConfirm

#define SizeOfHeapConfirm   (offsetof(xl_heap_confirm, offnum) + sizeof(OffsetNumber))

Definition at line 307 of file heapam_xlog.h.

◆ SizeOfHeapDelete

#define SizeOfHeapDelete   (offsetof(xl_heap_delete, flags) + sizeof(uint8))

Definition at line 115 of file heapam_xlog.h.

◆ SizeOfHeapFreezePage

#define SizeOfHeapFreezePage   (offsetof(xl_heap_freeze_page, isCatalogRel) + sizeof(bool))

Definition at line 357 of file heapam_xlog.h.

◆ SizeOfHeapHeader

#define SizeOfHeapHeader   (offsetof(xl_heap_header, t_hoff) + sizeof(uint8))

Definition at line 151 of file heapam_xlog.h.

◆ SizeOfHeapInplace

#define SizeOfHeapInplace   (offsetof(xl_heap_inplace, offnum) + sizeof(OffsetNumber))

Definition at line 316 of file heapam_xlog.h.

◆ SizeOfHeapInsert

#define SizeOfHeapInsert   (offsetof(xl_heap_insert, flags) + sizeof(uint8))

Definition at line 162 of file heapam_xlog.h.

◆ SizeOfHeapLock

#define SizeOfHeapLock   (offsetof(xl_heap_lock, flags) + sizeof(uint8))

Definition at line 288 of file heapam_xlog.h.

◆ SizeOfHeapLockUpdated

#define SizeOfHeapLockUpdated   (offsetof(xl_heap_lock_updated, flags) + sizeof(uint8))

Definition at line 299 of file heapam_xlog.h.

◆ SizeOfHeapMultiInsert

#define SizeOfHeapMultiInsert   offsetof(xl_heap_multi_insert, offsets)

Definition at line 182 of file heapam_xlog.h.

◆ SizeOfHeapNewCid

#define SizeOfHeapNewCid   (offsetof(xl_heap_new_cid, target_tid) + sizeof(ItemPointerData))

Definition at line 391 of file heapam_xlog.h.

◆ SizeOfHeapPrune

#define SizeOfHeapPrune   (offsetof(xl_heap_prune, isCatalogRel) + sizeof(bool))

Definition at line 253 of file heapam_xlog.h.

◆ SizeOfHeapTruncate

#define SizeOfHeapTruncate   (offsetof(xl_heap_truncate, relids))

Definition at line 136 of file heapam_xlog.h.

◆ SizeOfHeapUpdate

#define SizeOfHeapUpdate   (offsetof(xl_heap_update, new_offnum) + sizeof(OffsetNumber))

Definition at line 227 of file heapam_xlog.h.

◆ SizeOfHeapVacuum

#define SizeOfHeapVacuum   (offsetof(xl_heap_vacuum, nunused) + sizeof(uint16))

Definition at line 267 of file heapam_xlog.h.

◆ SizeOfHeapVisible

#define SizeOfHeapVisible   (offsetof(xl_heap_visible, flags) + sizeof(uint8))

Definition at line 371 of file heapam_xlog.h.

◆ SizeOfMultiInsertTuple

#define SizeOfMultiInsertTuple   (offsetof(xl_multi_insert_tuple, t_hoff) + sizeof(uint8))

Definition at line 193 of file heapam_xlog.h.

◆ XLH_DELETE_ALL_VISIBLE_CLEARED

#define XLH_DELETE_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 96 of file heapam_xlog.h.

◆ XLH_DELETE_CONTAINS_OLD

#define XLH_DELETE_CONTAINS_OLD    (XLH_DELETE_CONTAINS_OLD_TUPLE | XLH_DELETE_CONTAINS_OLD_KEY)

Definition at line 103 of file heapam_xlog.h.

◆ XLH_DELETE_CONTAINS_OLD_KEY

#define XLH_DELETE_CONTAINS_OLD_KEY   (1<<2)

Definition at line 98 of file heapam_xlog.h.

◆ XLH_DELETE_CONTAINS_OLD_TUPLE

#define XLH_DELETE_CONTAINS_OLD_TUPLE   (1<<1)

Definition at line 97 of file heapam_xlog.h.

◆ XLH_DELETE_IS_PARTITION_MOVE

#define XLH_DELETE_IS_PARTITION_MOVE   (1<<4)

Definition at line 100 of file heapam_xlog.h.

◆ XLH_DELETE_IS_SUPER

#define XLH_DELETE_IS_SUPER   (1<<3)

Definition at line 99 of file heapam_xlog.h.

◆ XLH_FREEZE_XVAC

#define XLH_FREEZE_XVAC   0x02

Definition at line 323 of file heapam_xlog.h.

◆ XLH_INSERT_ALL_FROZEN_SET

#define XLH_INSERT_ALL_FROZEN_SET   (1<<5)

Definition at line 73 of file heapam_xlog.h.

◆ XLH_INSERT_ALL_VISIBLE_CLEARED

#define XLH_INSERT_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 66 of file heapam_xlog.h.

◆ XLH_INSERT_CONTAINS_NEW_TUPLE

#define XLH_INSERT_CONTAINS_NEW_TUPLE   (1<<3)

Definition at line 69 of file heapam_xlog.h.

◆ XLH_INSERT_IS_SPECULATIVE

#define XLH_INSERT_IS_SPECULATIVE   (1<<2)

Definition at line 68 of file heapam_xlog.h.

◆ XLH_INSERT_LAST_IN_MULTI

#define XLH_INSERT_LAST_IN_MULTI   (1<<1)

Definition at line 67 of file heapam_xlog.h.

◆ XLH_INSERT_ON_TOAST_RELATION

#define XLH_INSERT_ON_TOAST_RELATION   (1<<4)

Definition at line 70 of file heapam_xlog.h.

◆ XLH_INVALID_XVAC

#define XLH_INVALID_XVAC   0x04

Definition at line 324 of file heapam_xlog.h.

◆ XLH_LOCK_ALL_FROZEN_CLEARED

#define XLH_LOCK_ALL_FROZEN_CLEARED   0x01

Definition at line 277 of file heapam_xlog.h.

◆ XLH_TRUNCATE_CASCADE

#define XLH_TRUNCATE_CASCADE   (1<<0)

Definition at line 120 of file heapam_xlog.h.

◆ XLH_TRUNCATE_RESTART_SEQS

#define XLH_TRUNCATE_RESTART_SEQS   (1<<1)

Definition at line 121 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_NEW_TUPLE

#define XLH_UPDATE_CONTAINS_NEW_TUPLE   (1<<4)

Definition at line 84 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_OLD

#define XLH_UPDATE_CONTAINS_OLD    (XLH_UPDATE_CONTAINS_OLD_TUPLE | XLH_UPDATE_CONTAINS_OLD_KEY)

Definition at line 89 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_OLD_KEY

#define XLH_UPDATE_CONTAINS_OLD_KEY   (1<<3)

Definition at line 83 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_OLD_TUPLE

#define XLH_UPDATE_CONTAINS_OLD_TUPLE   (1<<2)

Definition at line 82 of file heapam_xlog.h.

◆ XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED

#define XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED   (1<<1)

Definition at line 81 of file heapam_xlog.h.

◆ XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED

#define XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 79 of file heapam_xlog.h.

◆ XLH_UPDATE_PREFIX_FROM_OLD

#define XLH_UPDATE_PREFIX_FROM_OLD   (1<<5)

Definition at line 85 of file heapam_xlog.h.

◆ XLH_UPDATE_SUFFIX_FROM_OLD

#define XLH_UPDATE_SUFFIX_FROM_OLD   (1<<6)

Definition at line 86 of file heapam_xlog.h.

◆ XLHL_KEYS_UPDATED

#define XLHL_KEYS_UPDATED   0x10

Definition at line 274 of file heapam_xlog.h.

◆ XLHL_XMAX_EXCL_LOCK

#define XLHL_XMAX_EXCL_LOCK   0x04

Definition at line 272 of file heapam_xlog.h.

◆ XLHL_XMAX_IS_MULTI

#define XLHL_XMAX_IS_MULTI   0x01

Definition at line 270 of file heapam_xlog.h.

◆ XLHL_XMAX_KEYSHR_LOCK

#define XLHL_XMAX_KEYSHR_LOCK   0x08

Definition at line 273 of file heapam_xlog.h.

◆ XLHL_XMAX_LOCK_ONLY

#define XLHL_XMAX_LOCK_ONLY   0x02

Definition at line 271 of file heapam_xlog.h.

◆ XLOG_HEAP2_FREEZE_PAGE

#define XLOG_HEAP2_FREEZE_PAGE   0x30

Definition at line 56 of file heapam_xlog.h.

◆ XLOG_HEAP2_LOCK_UPDATED

#define XLOG_HEAP2_LOCK_UPDATED   0x60

Definition at line 59 of file heapam_xlog.h.

◆ XLOG_HEAP2_MULTI_INSERT

#define XLOG_HEAP2_MULTI_INSERT   0x50

Definition at line 58 of file heapam_xlog.h.

◆ XLOG_HEAP2_NEW_CID

#define XLOG_HEAP2_NEW_CID   0x70

Definition at line 60 of file heapam_xlog.h.

◆ XLOG_HEAP2_PRUNE

#define XLOG_HEAP2_PRUNE   0x10

Definition at line 54 of file heapam_xlog.h.

◆ XLOG_HEAP2_REWRITE

#define XLOG_HEAP2_REWRITE   0x00

Definition at line 53 of file heapam_xlog.h.

◆ XLOG_HEAP2_VACUUM

#define XLOG_HEAP2_VACUUM   0x20

Definition at line 55 of file heapam_xlog.h.

◆ XLOG_HEAP2_VISIBLE

#define XLOG_HEAP2_VISIBLE   0x40

Definition at line 57 of file heapam_xlog.h.

◆ XLOG_HEAP_CONFIRM

#define XLOG_HEAP_CONFIRM   0x50

Definition at line 37 of file heapam_xlog.h.

◆ XLOG_HEAP_DELETE

#define XLOG_HEAP_DELETE   0x10

Definition at line 33 of file heapam_xlog.h.

◆ XLOG_HEAP_HOT_UPDATE

#define XLOG_HEAP_HOT_UPDATE   0x40

Definition at line 36 of file heapam_xlog.h.

◆ XLOG_HEAP_INIT_PAGE

#define XLOG_HEAP_INIT_PAGE   0x80

Definition at line 46 of file heapam_xlog.h.

◆ XLOG_HEAP_INPLACE

#define XLOG_HEAP_INPLACE   0x70

Definition at line 39 of file heapam_xlog.h.

◆ XLOG_HEAP_INSERT

#define XLOG_HEAP_INSERT   0x00

Definition at line 32 of file heapam_xlog.h.

◆ XLOG_HEAP_LOCK

#define XLOG_HEAP_LOCK   0x60

Definition at line 38 of file heapam_xlog.h.

◆ XLOG_HEAP_OPMASK

#define XLOG_HEAP_OPMASK   0x70

Definition at line 41 of file heapam_xlog.h.

◆ XLOG_HEAP_TRUNCATE

#define XLOG_HEAP_TRUNCATE   0x30

Definition at line 35 of file heapam_xlog.h.

◆ XLOG_HEAP_UPDATE

#define XLOG_HEAP_UPDATE   0x20

Definition at line 34 of file heapam_xlog.h.

Typedef Documentation

◆ xl_heap_confirm

◆ xl_heap_delete

◆ xl_heap_freeze_page

◆ xl_heap_freeze_plan

◆ xl_heap_header

◆ xl_heap_inplace

◆ xl_heap_insert

◆ xl_heap_lock

typedef struct xl_heap_lock xl_heap_lock

◆ xl_heap_lock_updated

◆ xl_heap_multi_insert

◆ xl_heap_new_cid

◆ xl_heap_prune

typedef struct xl_heap_prune xl_heap_prune

◆ xl_heap_rewrite_mapping

◆ xl_heap_truncate

◆ xl_heap_update

◆ xl_heap_vacuum

◆ xl_heap_visible

◆ xl_multi_insert_tuple

Function Documentation

◆ heap2_desc()

void heap2_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 172 of file heapdesc.c.

173 {
174  char *rec = XLogRecGetData(record);
175  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
176 
177  info &= XLOG_HEAP_OPMASK;
178  if (info == XLOG_HEAP2_PRUNE)
179  {
180  xl_heap_prune *xlrec = (xl_heap_prune *) rec;
181 
182  appendStringInfo(buf, "snapshotConflictHorizon: %u, nredirected: %u, ndead: %u",
184  xlrec->nredirected,
185  xlrec->ndead);
186 
187  if (XLogRecHasBlockData(record, 0))
188  {
189  OffsetNumber *end;
190  OffsetNumber *redirected;
191  OffsetNumber *nowdead;
192  OffsetNumber *nowunused;
193  int nredirected;
194  int nunused;
195  Size datalen;
196 
197  redirected = (OffsetNumber *) XLogRecGetBlockData(record, 0,
198  &datalen);
199 
200  nredirected = xlrec->nredirected;
201  end = (OffsetNumber *) ((char *) redirected + datalen);
202  nowdead = redirected + (nredirected * 2);
203  nowunused = nowdead + xlrec->ndead;
204  nunused = (end - nowunused);
205  Assert(nunused >= 0);
206 
207  appendStringInfo(buf, ", nunused: %d", nunused);
208 
209  appendStringInfoString(buf, ", redirected:");
210  array_desc(buf, redirected, sizeof(OffsetNumber) * 2,
211  nredirected, &redirect_elem_desc, NULL);
212  appendStringInfoString(buf, ", dead:");
213  array_desc(buf, nowdead, sizeof(OffsetNumber), xlrec->ndead,
214  &offset_elem_desc, NULL);
215  appendStringInfoString(buf, ", unused:");
216  array_desc(buf, nowunused, sizeof(OffsetNumber), nunused,
217  &offset_elem_desc, NULL);
218  }
219  }
220  else if (info == XLOG_HEAP2_VACUUM)
221  {
222  xl_heap_vacuum *xlrec = (xl_heap_vacuum *) rec;
223 
224  appendStringInfo(buf, "nunused: %u", xlrec->nunused);
225 
226  if (XLogRecHasBlockData(record, 0))
227  {
228  OffsetNumber *nowunused;
229 
230  nowunused = (OffsetNumber *) XLogRecGetBlockData(record, 0, NULL);
231 
232  appendStringInfoString(buf, ", unused:");
233  array_desc(buf, nowunused, sizeof(OffsetNumber), xlrec->nunused,
234  &offset_elem_desc, NULL);
235  }
236  }
237  else if (info == XLOG_HEAP2_FREEZE_PAGE)
238  {
239  xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
240 
241  appendStringInfo(buf, "snapshotConflictHorizon: %u, nplans: %u",
242  xlrec->snapshotConflictHorizon, xlrec->nplans);
243 
244  if (XLogRecHasBlockData(record, 0))
245  {
246  xl_heap_freeze_plan *plans;
247  OffsetNumber *offsets;
248 
249  plans = (xl_heap_freeze_plan *) XLogRecGetBlockData(record, 0, NULL);
250  offsets = (OffsetNumber *) ((char *) plans +
251  (xlrec->nplans *
252  sizeof(xl_heap_freeze_plan)));
253  appendStringInfoString(buf, ", plans:");
254  array_desc(buf, plans, sizeof(xl_heap_freeze_plan), xlrec->nplans,
255  &plan_elem_desc, &offsets);
256  }
257  }
258  else if (info == XLOG_HEAP2_VISIBLE)
259  {
260  xl_heap_visible *xlrec = (xl_heap_visible *) rec;
261 
262  appendStringInfo(buf, "snapshotConflictHorizon: %u, flags: 0x%02X",
263  xlrec->snapshotConflictHorizon, xlrec->flags);
264  }
265  else if (info == XLOG_HEAP2_MULTI_INSERT)
266  {
268  bool isinit = (XLogRecGetInfo(record) & XLOG_HEAP_INIT_PAGE) != 0;
269 
270  appendStringInfo(buf, "ntuples: %d, flags: 0x%02X", xlrec->ntuples,
271  xlrec->flags);
272 
273  if (XLogRecHasBlockData(record, 0) && !isinit)
274  {
275  appendStringInfoString(buf, ", offsets:");
276  array_desc(buf, xlrec->offsets, sizeof(OffsetNumber),
277  xlrec->ntuples, &offset_elem_desc, NULL);
278  }
279  }
280  else if (info == XLOG_HEAP2_LOCK_UPDATED)
281  {
283 
284  appendStringInfo(buf, "xmax: %u, off: %u, ",
285  xlrec->xmax, xlrec->offnum);
286  infobits_desc(buf, xlrec->infobits_set, "infobits");
287  appendStringInfo(buf, ", flags: 0x%02X", xlrec->flags);
288  }
289  else if (info == XLOG_HEAP2_NEW_CID)
290  {
291  xl_heap_new_cid *xlrec = (xl_heap_new_cid *) rec;
292 
293  appendStringInfo(buf, "rel: %u/%u/%u, tid: %u/%u",
294  xlrec->target_locator.spcOid,
295  xlrec->target_locator.dbOid,
296  xlrec->target_locator.relNumber,
299  appendStringInfo(buf, ", cmin: %u, cmax: %u, combo: %u",
300  xlrec->cmin, xlrec->cmax, xlrec->combocid);
301  }
302 }
unsigned char uint8
Definition: c.h:488
size_t Size
Definition: c.h:589
#define XLOG_HEAP2_PRUNE
Definition: heapam_xlog.h:54
#define XLOG_HEAP2_MULTI_INSERT
Definition: heapam_xlog.h:58
#define XLOG_HEAP2_VACUUM
Definition: heapam_xlog.h:55
#define XLOG_HEAP_OPMASK
Definition: heapam_xlog.h:41
struct xl_heap_freeze_plan xl_heap_freeze_plan
#define XLOG_HEAP2_LOCK_UPDATED
Definition: heapam_xlog.h:59
#define XLOG_HEAP2_FREEZE_PAGE
Definition: heapam_xlog.h:56
#define XLOG_HEAP2_NEW_CID
Definition: heapam_xlog.h:60
#define XLOG_HEAP2_VISIBLE
Definition: heapam_xlog.h:57
#define XLOG_HEAP_INIT_PAGE
Definition: heapam_xlog.h:46
static void plan_elem_desc(StringInfo buf, void *plan, void *data)
Definition: heapdesc.c:75
static void infobits_desc(StringInfo buf, uint8 infobits, const char *keyname)
Definition: heapdesc.c:25
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
Definition: itemptr.h:124
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
Definition: itemptr.h:103
Assert(fmt[strlen(fmt) - 1] !='\n')
uint16 OffsetNumber
Definition: off.h:24
static char * buf
Definition: pg_test_fsync.c:67
void redirect_elem_desc(StringInfo buf, void *offset, void *data)
void array_desc(StringInfo buf, void *array, size_t elem_size, int count, void(*elem_desc)(StringInfo buf, void *elem, void *data), void *data)
void offset_elem_desc(StringInfo buf, void *offset, void *data)
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
RelFileNumber relNumber
TransactionId snapshotConflictHorizon
Definition: heapam_xlog.h:347
TransactionId xmax
Definition: heapam_xlog.h:293
OffsetNumber offnum
Definition: heapam_xlog.h:294
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER]
Definition: heapam_xlog.h:179
CommandId cmin
Definition: heapam_xlog.h:380
CommandId combocid
Definition: heapam_xlog.h:382
ItemPointerData target_tid
Definition: heapam_xlog.h:388
CommandId cmax
Definition: heapam_xlog.h:381
RelFileLocator target_locator
Definition: heapam_xlog.h:387
TransactionId snapshotConflictHorizon
Definition: heapam_xlog.h:245
uint16 nredirected
Definition: heapam_xlog.h:246
TransactionId snapshotConflictHorizon
Definition: heapam_xlog.h:367
char * XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len)
Definition: xlogreader.c:2015
#define XLogRecHasBlockData(decoder, block_id)
Definition: xlogreader.h:427
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:410
#define XLogRecGetData(decoder)
Definition: xlogreader.h:415
#define XLR_INFO_MASK
Definition: xlogrecord.h:62

References appendStringInfo(), appendStringInfoString(), array_desc(), Assert(), buf, xl_heap_new_cid::cmax, xl_heap_new_cid::cmin, xl_heap_new_cid::combocid, RelFileLocator::dbOid, xl_heap_multi_insert::flags, xl_heap_lock_updated::flags, xl_heap_visible::flags, infobits_desc(), xl_heap_lock_updated::infobits_set, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), xl_heap_prune::ndead, xl_heap_freeze_page::nplans, xl_heap_prune::nredirected, xl_heap_multi_insert::ntuples, xl_heap_vacuum::nunused, xl_heap_lock_updated::offnum, offset_elem_desc(), xl_heap_multi_insert::offsets, plan_elem_desc(), redirect_elem_desc(), RelFileLocator::relNumber, xl_heap_prune::snapshotConflictHorizon, xl_heap_freeze_page::snapshotConflictHorizon, xl_heap_visible::snapshotConflictHorizon, RelFileLocator::spcOid, xl_heap_new_cid::target_locator, xl_heap_new_cid::target_tid, XLOG_HEAP2_FREEZE_PAGE, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_PRUNE, XLOG_HEAP2_VACUUM, XLOG_HEAP2_VISIBLE, XLOG_HEAP_INIT_PAGE, XLOG_HEAP_OPMASK, XLogRecGetBlockData(), XLogRecGetData, XLogRecGetInfo, XLogRecHasBlockData, XLR_INFO_MASK, and xl_heap_lock_updated::xmax.

◆ heap2_identify()

const char* heap2_identify ( uint8  info)

Definition at line 350 of file heapdesc.c.

351 {
352  const char *id = NULL;
353 
354  switch (info & ~XLR_INFO_MASK)
355  {
356  case XLOG_HEAP2_PRUNE:
357  id = "PRUNE";
358  break;
359  case XLOG_HEAP2_VACUUM:
360  id = "VACUUM";
361  break;
363  id = "FREEZE_PAGE";
364  break;
365  case XLOG_HEAP2_VISIBLE:
366  id = "VISIBLE";
367  break;
369  id = "MULTI_INSERT";
370  break;
372  id = "MULTI_INSERT+INIT";
373  break;
375  id = "LOCK_UPDATED";
376  break;
377  case XLOG_HEAP2_NEW_CID:
378  id = "NEW_CID";
379  break;
380  case XLOG_HEAP2_REWRITE:
381  id = "REWRITE";
382  break;
383  }
384 
385  return id;
386 }
#define XLOG_HEAP2_REWRITE
Definition: heapam_xlog.h:53

References XLOG_HEAP2_FREEZE_PAGE, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_PRUNE, XLOG_HEAP2_REWRITE, XLOG_HEAP2_VACUUM, XLOG_HEAP2_VISIBLE, XLOG_HEAP_INIT_PAGE, and XLR_INFO_MASK.

◆ heap2_redo()

void heap2_redo ( XLogReaderState record)

Definition at line 10008 of file heapam.c.

10009 {
10010  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
10011 
10012  switch (info & XLOG_HEAP_OPMASK)
10013  {
10014  case XLOG_HEAP2_PRUNE:
10015  heap_xlog_prune(record);
10016  break;
10017  case XLOG_HEAP2_VACUUM:
10018  heap_xlog_vacuum(record);
10019  break;
10021  heap_xlog_freeze_page(record);
10022  break;
10023  case XLOG_HEAP2_VISIBLE:
10024  heap_xlog_visible(record);
10025  break;
10027  heap_xlog_multi_insert(record);
10028  break;
10030  heap_xlog_lock_updated(record);
10031  break;
10032  case XLOG_HEAP2_NEW_CID:
10033 
10034  /*
10035  * Nothing to do on a real replay, only used during logical
10036  * decoding.
10037  */
10038  break;
10039  case XLOG_HEAP2_REWRITE:
10040  heap_xlog_logical_rewrite(record);
10041  break;
10042  default:
10043  elog(PANIC, "heap2_redo: unknown op code %u", info);
10044  }
10045 }
#define PANIC
Definition: elog.h:42
static void heap_xlog_prune(XLogReaderState *record)
Definition: heapam.c:8755
static void heap_xlog_vacuum(XLogReaderState *record)
Definition: heapam.c:8843
static void heap_xlog_lock_updated(XLogReaderState *record)
Definition: heapam.c:9861
static void heap_xlog_multi_insert(XLogReaderState *record)
Definition: heapam.c:9335
static void heap_xlog_visible(XLogReaderState *record)
Definition: heapam.c:8918
static void heap_xlog_freeze_page(XLogReaderState *record)
Definition: heapam.c:9050
void heap_xlog_logical_rewrite(XLogReaderState *r)
Definition: rewriteheap.c:1107

References elog(), heap_xlog_freeze_page(), heap_xlog_lock_updated(), heap_xlog_logical_rewrite(), heap_xlog_multi_insert(), heap_xlog_prune(), heap_xlog_vacuum(), heap_xlog_visible(), PANIC, XLOG_HEAP2_FREEZE_PAGE, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_PRUNE, XLOG_HEAP2_REWRITE, XLOG_HEAP2_VACUUM, XLOG_HEAP2_VISIBLE, XLOG_HEAP_OPMASK, XLogRecGetInfo, and XLR_INFO_MASK.

◆ heap_desc()

void heap_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 95 of file heapdesc.c.

96 {
97  char *rec = XLogRecGetData(record);
98  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
99 
100  info &= XLOG_HEAP_OPMASK;
101  if (info == XLOG_HEAP_INSERT)
102  {
103  xl_heap_insert *xlrec = (xl_heap_insert *) rec;
104 
105  appendStringInfo(buf, "off: %u, flags: 0x%02X",
106  xlrec->offnum,
107  xlrec->flags);
108  }
109  else if (info == XLOG_HEAP_DELETE)
110  {
111  xl_heap_delete *xlrec = (xl_heap_delete *) rec;
112 
113  appendStringInfo(buf, "xmax: %u, off: %u, ",
114  xlrec->xmax, xlrec->offnum);
115  infobits_desc(buf, xlrec->infobits_set, "infobits");
116  appendStringInfo(buf, ", flags: 0x%02X", xlrec->flags);
117  }
118  else if (info == XLOG_HEAP_UPDATE)
119  {
120  xl_heap_update *xlrec = (xl_heap_update *) rec;
121 
122  appendStringInfo(buf, "old_xmax: %u, old_off: %u, ",
123  xlrec->old_xmax, xlrec->old_offnum);
124  infobits_desc(buf, xlrec->old_infobits_set, "old_infobits");
125  appendStringInfo(buf, ", flags: 0x%02X, new_xmax: %u, new_off: %u",
126  xlrec->flags, xlrec->new_xmax, xlrec->new_offnum);
127  }
128  else if (info == XLOG_HEAP_HOT_UPDATE)
129  {
130  xl_heap_update *xlrec = (xl_heap_update *) rec;
131 
132  appendStringInfo(buf, "old_xmax: %u, old_off: %u, ",
133  xlrec->old_xmax, xlrec->old_offnum);
134  infobits_desc(buf, xlrec->old_infobits_set, "old_infobits");
135  appendStringInfo(buf, ", flags: 0x%02X, new_xmax: %u, new_off: %u",
136  xlrec->flags, xlrec->new_xmax, xlrec->new_offnum);
137  }
138  else if (info == XLOG_HEAP_TRUNCATE)
139  {
140  xl_heap_truncate *xlrec = (xl_heap_truncate *) rec;
141 
142  truncate_flags_desc(buf, xlrec->flags);
143  appendStringInfo(buf, ", nrelids: %u", xlrec->nrelids);
144  appendStringInfoString(buf, ", relids:");
145  array_desc(buf, xlrec->relids, sizeof(Oid), xlrec->nrelids,
146  &oid_elem_desc, NULL);
147  }
148  else if (info == XLOG_HEAP_CONFIRM)
149  {
150  xl_heap_confirm *xlrec = (xl_heap_confirm *) rec;
151 
152  appendStringInfo(buf, "off: %u", xlrec->offnum);
153  }
154  else if (info == XLOG_HEAP_LOCK)
155  {
156  xl_heap_lock *xlrec = (xl_heap_lock *) rec;
157 
158  appendStringInfo(buf, "xmax: %u, off: %u, ",
159  xlrec->xmax, xlrec->offnum);
160  infobits_desc(buf, xlrec->infobits_set, "infobits");
161  appendStringInfo(buf, ", flags: 0x%02X", xlrec->flags);
162  }
163  else if (info == XLOG_HEAP_INPLACE)
164  {
165  xl_heap_inplace *xlrec = (xl_heap_inplace *) rec;
166 
167  appendStringInfo(buf, "off: %u", xlrec->offnum);
168  }
169 }
#define XLOG_HEAP_HOT_UPDATE
Definition: heapam_xlog.h:36
#define XLOG_HEAP_DELETE
Definition: heapam_xlog.h:33
#define XLOG_HEAP_TRUNCATE
Definition: heapam_xlog.h:35
#define XLOG_HEAP_UPDATE
Definition: heapam_xlog.h:34
#define XLOG_HEAP_INPLACE
Definition: heapam_xlog.h:39
#define XLOG_HEAP_LOCK
Definition: heapam_xlog.h:38
#define XLOG_HEAP_INSERT
Definition: heapam_xlog.h:32
#define XLOG_HEAP_CONFIRM
Definition: heapam_xlog.h:37
static void truncate_flags_desc(StringInfo buf, uint8 flags)
Definition: heapdesc.c:54
unsigned int Oid
Definition: postgres_ext.h:31
void oid_elem_desc(StringInfo buf, void *relid, void *data)
OffsetNumber offnum
Definition: heapam_xlog.h:304
TransactionId xmax
Definition: heapam_xlog.h:109
OffsetNumber offnum
Definition: heapam_xlog.h:110
uint8 infobits_set
Definition: heapam_xlog.h:111
OffsetNumber offnum
Definition: heapam_xlog.h:312
OffsetNumber offnum
Definition: heapam_xlog.h:156
uint8 infobits_set
Definition: heapam_xlog.h:284
OffsetNumber offnum
Definition: heapam_xlog.h:283
TransactionId xmax
Definition: heapam_xlog.h:282
Oid relids[FLEXIBLE_ARRAY_MEMBER]
Definition: heapam_xlog.h:133
TransactionId new_xmax
Definition: heapam_xlog.h:218
uint8 old_infobits_set
Definition: heapam_xlog.h:216
TransactionId old_xmax
Definition: heapam_xlog.h:214
OffsetNumber old_offnum
Definition: heapam_xlog.h:215
OffsetNumber new_offnum
Definition: heapam_xlog.h:219

References appendStringInfo(), appendStringInfoString(), array_desc(), buf, xl_heap_delete::flags, xl_heap_truncate::flags, xl_heap_insert::flags, xl_heap_update::flags, xl_heap_lock::flags, infobits_desc(), xl_heap_delete::infobits_set, xl_heap_lock::infobits_set, xl_heap_update::new_offnum, xl_heap_update::new_xmax, xl_heap_truncate::nrelids, xl_heap_delete::offnum, xl_heap_insert::offnum, xl_heap_lock::offnum, xl_heap_confirm::offnum, xl_heap_inplace::offnum, oid_elem_desc(), xl_heap_update::old_infobits_set, xl_heap_update::old_offnum, xl_heap_update::old_xmax, xl_heap_truncate::relids, truncate_flags_desc(), XLOG_HEAP_CONFIRM, XLOG_HEAP_DELETE, XLOG_HEAP_HOT_UPDATE, XLOG_HEAP_INPLACE, XLOG_HEAP_INSERT, XLOG_HEAP_LOCK, XLOG_HEAP_OPMASK, XLOG_HEAP_TRUNCATE, XLOG_HEAP_UPDATE, XLogRecGetData, XLogRecGetInfo, XLR_INFO_MASK, xl_heap_delete::xmax, and xl_heap_lock::xmax.

◆ heap_identify()

const char* heap_identify ( uint8  info)

Definition at line 305 of file heapdesc.c.

306 {
307  const char *id = NULL;
308 
309  switch (info & ~XLR_INFO_MASK)
310  {
311  case XLOG_HEAP_INSERT:
312  id = "INSERT";
313  break;
315  id = "INSERT+INIT";
316  break;
317  case XLOG_HEAP_DELETE:
318  id = "DELETE";
319  break;
320  case XLOG_HEAP_UPDATE:
321  id = "UPDATE";
322  break;
324  id = "UPDATE+INIT";
325  break;
327  id = "HOT_UPDATE";
328  break;
330  id = "HOT_UPDATE+INIT";
331  break;
332  case XLOG_HEAP_TRUNCATE:
333  id = "TRUNCATE";
334  break;
335  case XLOG_HEAP_CONFIRM:
336  id = "HEAP_CONFIRM";
337  break;
338  case XLOG_HEAP_LOCK:
339  id = "LOCK";
340  break;
341  case XLOG_HEAP_INPLACE:
342  id = "INPLACE";
343  break;
344  }
345 
346  return id;
347 }

References XLOG_HEAP_CONFIRM, XLOG_HEAP_DELETE, XLOG_HEAP_HOT_UPDATE, XLOG_HEAP_INIT_PAGE, XLOG_HEAP_INPLACE, XLOG_HEAP_INSERT, XLOG_HEAP_LOCK, XLOG_HEAP_TRUNCATE, XLOG_HEAP_UPDATE, and XLR_INFO_MASK.

◆ heap_mask()

void heap_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 10051 of file heapam.c.

10052 {
10053  Page page = (Page) pagedata;
10054  OffsetNumber off;
10055 
10057 
10058  mask_page_hint_bits(page);
10059  mask_unused_space(page);
10060 
10061  for (off = 1; off <= PageGetMaxOffsetNumber(page); off++)
10062  {
10063  ItemId iid = PageGetItemId(page, off);
10064  char *page_item;
10065 
10066  page_item = (char *) (page + ItemIdGetOffset(iid));
10067 
10068  if (ItemIdIsNormal(iid))
10069  {
10070  HeapTupleHeader page_htup = (HeapTupleHeader) page_item;
10071 
10072  /*
10073  * If xmin of a tuple is not yet frozen, we should ignore
10074  * differences in hint bits, since they can be set without
10075  * emitting WAL.
10076  */
10077  if (!HeapTupleHeaderXminFrozen(page_htup))
10078  page_htup->t_infomask &= ~HEAP_XACT_MASK;
10079  else
10080  {
10081  /* Still we need to mask xmax hint bits. */
10082  page_htup->t_infomask &= ~HEAP_XMAX_INVALID;
10083  page_htup->t_infomask &= ~HEAP_XMAX_COMMITTED;
10084  }
10085 
10086  /*
10087  * During replay, we set Command Id to FirstCommandId. Hence, mask
10088  * it. See heap_xlog_insert() for details.
10089  */
10090  page_htup->t_choice.t_heap.t_field3.t_cid = MASK_MARKER;
10091 
10092  /*
10093  * For a speculative tuple, heap_insert() does not set ctid in the
10094  * caller-passed heap tuple itself, leaving the ctid field to
10095  * contain a speculative token value - a per-backend monotonically
10096  * increasing identifier. Besides, it does not WAL-log ctid under
10097  * any circumstances.
10098  *
10099  * During redo, heap_xlog_insert() sets t_ctid to current block
10100  * number and self offset number. It doesn't care about any
10101  * speculative insertions on the primary. Hence, we set t_ctid to
10102  * current block number and self offset number to ignore any
10103  * inconsistency.
10104  */
10105  if (HeapTupleHeaderIsSpeculative(page_htup))
10106  ItemPointerSet(&page_htup->t_ctid, blkno, off);
10107 
10108  /*
10109  * NB: Not ignoring ctid changes due to the tuple having moved
10110  * (i.e. HeapTupleHeaderIndicatesMovedPartitions), because that's
10111  * important information that needs to be in-sync between primary
10112  * and standby, and thus is WAL logged.
10113  */
10114  }
10115 
10116  /*
10117  * Ignore any padding bytes after the tuple, when the length of the
10118  * item is not MAXALIGNed.
10119  */
10120  if (ItemIdHasStorage(iid))
10121  {
10122  int len = ItemIdGetLength(iid);
10123  int padlen = MAXALIGN(len) - len;
10124 
10125  if (padlen > 0)
10126  memset(page_item + len, MASK_MARKER, padlen);
10127  }
10128  }
10129 }
void mask_page_lsn_and_checksum(Page page)
Definition: bufmask.c:31
void mask_unused_space(Page page)
Definition: bufmask.c:71
void mask_page_hint_bits(Page page)
Definition: bufmask.c:46
#define MASK_MARKER
Definition: bufmask.h:24
Pointer Page
Definition: bufpage.h:78
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
Definition: bufpage.h:240
static OffsetNumber PageGetMaxOffsetNumber(Page page)
Definition: bufpage.h:369
#define MAXALIGN(LEN)
Definition: c.h:795
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
#define HEAP_XMAX_COMMITTED
Definition: htup_details.h:207
#define HEAP_XACT_MASK
Definition: htup_details.h:215
#define HeapTupleHeaderXminFrozen(tup)
Definition: htup_details.h:331
#define HEAP_XMAX_INVALID
Definition: htup_details.h:208
#define HeapTupleHeaderIsSpeculative(tup)
Definition: htup_details.h:428
#define ItemIdGetLength(itemId)
Definition: itemid.h:59
#define ItemIdIsNormal(itemId)
Definition: itemid.h:99
#define ItemIdGetOffset(itemId)
Definition: itemid.h:65
#define ItemIdHasStorage(itemId)
Definition: itemid.h:120
static void ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber offNum)
Definition: itemptr.h:135
const void size_t len
CommandId t_cid
Definition: htup_details.h:129
union HeapTupleFields::@43 t_field3
union HeapTupleHeaderData::@44 t_choice
ItemPointerData t_ctid
Definition: htup_details.h:161
HeapTupleFields t_heap
Definition: htup_details.h:157

References HEAP_XACT_MASK, HEAP_XMAX_COMMITTED, HEAP_XMAX_INVALID, HeapTupleHeaderIsSpeculative, HeapTupleHeaderXminFrozen, ItemIdGetLength, ItemIdGetOffset, ItemIdHasStorage, ItemIdIsNormal, ItemPointerSet(), len, MASK_MARKER, mask_page_hint_bits(), mask_page_lsn_and_checksum(), mask_unused_space(), MAXALIGN, PageGetItemId(), PageGetMaxOffsetNumber(), and HeapTupleHeaderData::t_infomask.

◆ heap_redo()

void heap_redo ( XLogReaderState record)

Definition at line 9962 of file heapam.c.

9963 {
9964  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
9965 
9966  /*
9967  * These operations don't overwrite MVCC data so no conflict processing is
9968  * required. The ones in heap2 rmgr do.
9969  */
9970 
9971  switch (info & XLOG_HEAP_OPMASK)
9972  {
9973  case XLOG_HEAP_INSERT:
9974  heap_xlog_insert(record);
9975  break;
9976  case XLOG_HEAP_DELETE:
9977  heap_xlog_delete(record);
9978  break;
9979  case XLOG_HEAP_UPDATE:
9980  heap_xlog_update(record, false);
9981  break;
9982  case XLOG_HEAP_TRUNCATE:
9983 
9984  /*
9985  * TRUNCATE is a no-op because the actions are already logged as
9986  * SMGR WAL records. TRUNCATE WAL record only exists for logical
9987  * decoding.
9988  */
9989  break;
9990  case XLOG_HEAP_HOT_UPDATE:
9991  heap_xlog_update(record, true);
9992  break;
9993  case XLOG_HEAP_CONFIRM:
9994  heap_xlog_confirm(record);
9995  break;
9996  case XLOG_HEAP_LOCK:
9997  heap_xlog_lock(record);
9998  break;
9999  case XLOG_HEAP_INPLACE:
10000  heap_xlog_inplace(record);
10001  break;
10002  default:
10003  elog(PANIC, "heap_redo: unknown op code %u", info);
10004  }
10005 }
static void heap_xlog_insert(XLogReaderState *record)
Definition: heapam.c:9215
static void heap_xlog_update(XLogReaderState *record, bool hot_update)
Definition: heapam.c:9482
static void heap_xlog_delete(XLogReaderState *record)
Definition: heapam.c:9142
static void heap_xlog_lock(XLogReaderState *record)
Definition: heapam.c:9790
static void heap_xlog_inplace(XLogReaderState *record)
Definition: heapam.c:9921
static void heap_xlog_confirm(XLogReaderState *record)
Definition: heapam.c:9754

References elog(), heap_xlog_confirm(), heap_xlog_delete(), heap_xlog_inplace(), heap_xlog_insert(), heap_xlog_lock(), heap_xlog_update(), PANIC, XLOG_HEAP_CONFIRM, XLOG_HEAP_DELETE, XLOG_HEAP_HOT_UPDATE, XLOG_HEAP_INPLACE, XLOG_HEAP_INSERT, XLOG_HEAP_LOCK, XLOG_HEAP_OPMASK, XLOG_HEAP_TRUNCATE, XLOG_HEAP_UPDATE, XLogRecGetInfo, and XLR_INFO_MASK.

◆ heap_xlog_logical_rewrite()

void heap_xlog_logical_rewrite ( XLogReaderState r)

Definition at line 1107 of file rewriteheap.c.

1108 {
1109  char path[MAXPGPATH];
1110  int fd;
1111  xl_heap_rewrite_mapping *xlrec;
1112  uint32 len;
1113  char *data;
1114 
1115  xlrec = (xl_heap_rewrite_mapping *) XLogRecGetData(r);
1116 
1117  snprintf(path, MAXPGPATH,
1118  "pg_logical/mappings/" LOGICAL_REWRITE_FORMAT,
1119  xlrec->mapped_db, xlrec->mapped_rel,
1120  LSN_FORMAT_ARGS(xlrec->start_lsn),
1121  xlrec->mapped_xid, XLogRecGetXid(r));
1122 
1123  fd = OpenTransientFile(path,
1124  O_CREAT | O_WRONLY | PG_BINARY);
1125  if (fd < 0)
1126  ereport(ERROR,
1128  errmsg("could not create file \"%s\": %m", path)));
1129 
1130  /*
1131  * Truncate all data that's not guaranteed to have been safely fsynced (by
1132  * previous record or by the last checkpoint).
1133  */
1135  if (ftruncate(fd, xlrec->offset) != 0)
1136  ereport(ERROR,
1138  errmsg("could not truncate file \"%s\" to %u: %m",
1139  path, (uint32) xlrec->offset)));
1141 
1142  data = XLogRecGetData(r) + sizeof(*xlrec);
1143 
1144  len = xlrec->num_mappings * sizeof(LogicalRewriteMappingData);
1145 
1146  /* write out tail end of mapping file (again) */
1147  errno = 0;
1149  if (pg_pwrite(fd, data, len, xlrec->offset) != len)
1150  {
1151  /* if write didn't set errno, assume problem is no disk space */
1152  if (errno == 0)
1153  errno = ENOSPC;
1154  ereport(ERROR,
1156  errmsg("could not write to file \"%s\": %m", path)));
1157  }
1159 
1160  /*
1161  * Now fsync all previously written data. We could improve things and only
1162  * do this for the last write to a file, but the required bookkeeping
1163  * doesn't seem worth the trouble.
1164  */
1166  if (pg_fsync(fd) != 0)
1169  errmsg("could not fsync file \"%s\": %m", path)));
1171 
1172  if (CloseTransientFile(fd) != 0)
1173  ereport(ERROR,
1175  errmsg("could not close file \"%s\": %m", path)));
1176 }
unsigned int uint32
Definition: c.h:490
#define PG_BINARY
Definition: c.h:1278
int errcode_for_file_access(void)
Definition: elog.c:881
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
int CloseTransientFile(int fd)
Definition: fd.c:2706
int data_sync_elevel(int elevel)
Definition: fd.c:3833
int pg_fsync(int fd)
Definition: fd.c:361
int OpenTransientFile(const char *fileName, int fileFlags)
Definition: fd.c:2530
#define MAXPGPATH
const void * data
#define pg_pwrite
Definition: port.h:226
#define snprintf
Definition: port.h:238
static int fd(const char *x, int i)
Definition: preproc-init.c:105
#define LOGICAL_REWRITE_FORMAT
Definition: rewriteheap.h:54
struct LogicalRewriteMappingData LogicalRewriteMappingData
TransactionId mapped_xid
Definition: heapam_xlog.h:396
@ WAIT_EVENT_LOGICAL_REWRITE_MAPPING_SYNC
Definition: wait_event.h:195
@ WAIT_EVENT_LOGICAL_REWRITE_MAPPING_WRITE
Definition: wait_event.h:196
@ WAIT_EVENT_LOGICAL_REWRITE_TRUNCATE
Definition: wait_event.h:198
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: wait_event.h:271
static void pgstat_report_wait_end(void)
Definition: wait_event.h:287
#define ftruncate(a, b)
Definition: win32_port.h:82
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:43
#define XLogRecGetXid(decoder)
Definition: xlogreader.h:412

References CloseTransientFile(), data, data_sync_elevel(), ereport, errcode_for_file_access(), errmsg(), ERROR, fd(), ftruncate, len, LOGICAL_REWRITE_FORMAT, LSN_FORMAT_ARGS, xl_heap_rewrite_mapping::mapped_db, xl_heap_rewrite_mapping::mapped_rel, xl_heap_rewrite_mapping::mapped_xid, MAXPGPATH, xl_heap_rewrite_mapping::num_mappings, xl_heap_rewrite_mapping::offset, OpenTransientFile(), PG_BINARY, pg_fsync(), pg_pwrite, pgstat_report_wait_end(), pgstat_report_wait_start(), snprintf, xl_heap_rewrite_mapping::start_lsn, WAIT_EVENT_LOGICAL_REWRITE_MAPPING_SYNC, WAIT_EVENT_LOGICAL_REWRITE_MAPPING_WRITE, WAIT_EVENT_LOGICAL_REWRITE_TRUNCATE, XLogRecGetData, and XLogRecGetXid.

Referenced by heap2_redo().

◆ HeapTupleHeaderAdvanceConflictHorizon()

void HeapTupleHeaderAdvanceConflictHorizon ( HeapTupleHeader  tuple,
TransactionId snapshotConflictHorizon 
)

Definition at line 7492 of file heapam.c.

7494 {
7495  TransactionId xmin = HeapTupleHeaderGetXmin(tuple);
7497  TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
7498 
7499  if (tuple->t_infomask & HEAP_MOVED)
7500  {
7501  if (TransactionIdPrecedes(*snapshotConflictHorizon, xvac))
7502  *snapshotConflictHorizon = xvac;
7503  }
7504 
7505  /*
7506  * Ignore tuples inserted by an aborted transaction or if the tuple was
7507  * updated/deleted by the inserting transaction.
7508  *
7509  * Look for a committed hint bit, or if no xmin bit is set, check clog.
7510  */
7511  if (HeapTupleHeaderXminCommitted(tuple) ||
7513  {
7514  if (xmax != xmin &&
7515  TransactionIdFollows(xmax, *snapshotConflictHorizon))
7516  *snapshotConflictHorizon = xmax;
7517  }
7518 }
uint32 TransactionId
Definition: c.h:636
#define HeapTupleHeaderGetXvac(tup)
Definition: htup_details.h:411
#define HeapTupleHeaderGetXmin(tup)
Definition: htup_details.h:309
#define HEAP_MOVED
Definition: htup_details.h:213
#define HeapTupleHeaderXminCommitted(tup)
Definition: htup_details.h:320
#define HeapTupleHeaderGetUpdateXid(tup)
Definition: htup_details.h:361
#define HeapTupleHeaderXminInvalid(tup)
Definition: htup_details.h:325
bool TransactionIdDidCommit(TransactionId transactionId)
Definition: transam.c:126
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition: transam.c:280
bool TransactionIdFollows(TransactionId id1, TransactionId id2)
Definition: transam.c:314

References HEAP_MOVED, HeapTupleHeaderGetUpdateXid, HeapTupleHeaderGetXmin, HeapTupleHeaderGetXvac, HeapTupleHeaderXminCommitted, HeapTupleHeaderXminInvalid, HeapTupleHeaderData::t_infomask, TransactionIdDidCommit(), TransactionIdFollows(), and TransactionIdPrecedes().

Referenced by heap_index_delete_tuples(), and heap_prune_chain().

◆ log_heap_visible()

XLogRecPtr log_heap_visible ( Relation  rel,
Buffer  heap_buffer,
Buffer  vm_buffer,
TransactionId  snapshotConflictHorizon,
uint8  vmflags 
)

Definition at line 8324 of file heapam.c.

8326 {
8327  xl_heap_visible xlrec;
8328  XLogRecPtr recptr;
8329  uint8 flags;
8330 
8331  Assert(BufferIsValid(heap_buffer));
8332  Assert(BufferIsValid(vm_buffer));
8333 
8334  xlrec.snapshotConflictHorizon = snapshotConflictHorizon;
8335  xlrec.flags = vmflags;
8338  XLogBeginInsert();
8339  XLogRegisterData((char *) &xlrec, SizeOfHeapVisible);
8340 
8341  XLogRegisterBuffer(0, vm_buffer, 0);
8342 
8343  flags = REGBUF_STANDARD;
8344  if (!XLogHintBitIsNeeded())
8345  flags |= REGBUF_NO_IMAGE;
8346  XLogRegisterBuffer(1, heap_buffer, flags);
8347 
8348  recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_VISIBLE);
8349 
8350  return recptr;
8351 }
static bool BufferIsValid(Buffer bufnum)
Definition: bufmgr.h:303
#define SizeOfHeapVisible
Definition: heapam_xlog.h:371
#define RelationIsAccessibleInLogicalDecoding(relation)
Definition: rel.h:685
#define VISIBILITYMAP_XLOG_CATALOG_REL
#define XLogHintBitIsNeeded()
Definition: xlog.h:115
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void XLogRegisterData(char *data, uint32 len)
Definition: xloginsert.c:351
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:461
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:243
void XLogBeginInsert(void)
Definition: xloginsert.c:150
#define REGBUF_STANDARD
Definition: xloginsert.h:34
#define REGBUF_NO_IMAGE
Definition: xloginsert.h:32

References Assert(), BufferIsValid(), xl_heap_visible::flags, REGBUF_NO_IMAGE, REGBUF_STANDARD, RelationIsAccessibleInLogicalDecoding, SizeOfHeapVisible, xl_heap_visible::snapshotConflictHorizon, VISIBILITYMAP_XLOG_CATALOG_REL, XLOG_HEAP2_VISIBLE, XLogBeginInsert(), XLogHintBitIsNeeded, XLogInsert(), XLogRegisterBuffer(), and XLogRegisterData().

Referenced by visibilitymap_set().