PostgreSQL Source Code  git master
heapdesc.c File Reference
#include "postgres.h"
#include "access/heapam_xlog.h"
Include dependency graph for heapdesc.c:

Go to the source code of this file.

Functions

static void out_infobits (StringInfo buf, uint8 infobits)
 
void heap_desc (StringInfo buf, XLogReaderState *record)
 
void heap2_desc (StringInfo buf, XLogReaderState *record)
 
const char * heap_identify (uint8 info)
 
const char * heap2_identify (uint8 info)
 

Function Documentation

◆ heap2_desc()

void heap2_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 118 of file heapdesc.c.

119 {
120  char *rec = XLogRecGetData(record);
121  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
122 
123  info &= XLOG_HEAP_OPMASK;
124  if (info == XLOG_HEAP2_PRUNE)
125  {
126  xl_heap_prune *xlrec = (xl_heap_prune *) rec;
127 
128  appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
129  xlrec->latestRemovedXid,
130  xlrec->nredirected,
131  xlrec->ndead);
132  }
133  else if (info == XLOG_HEAP2_VACUUM)
134  {
135  xl_heap_vacuum *xlrec = (xl_heap_vacuum *) rec;
136 
137  appendStringInfo(buf, "nunused %u", xlrec->nunused);
138  }
139  else if (info == XLOG_HEAP2_FREEZE_PAGE)
140  {
141  xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
142 
143  appendStringInfo(buf, "cutoff xid %u ntuples %u",
144  xlrec->cutoff_xid, xlrec->ntuples);
145  }
146  else if (info == XLOG_HEAP2_VISIBLE)
147  {
148  xl_heap_visible *xlrec = (xl_heap_visible *) rec;
149 
150  appendStringInfo(buf, "cutoff xid %u flags 0x%02X",
151  xlrec->cutoff_xid, xlrec->flags);
152  }
153  else if (info == XLOG_HEAP2_MULTI_INSERT)
154  {
156 
157  appendStringInfo(buf, "%d tuples flags 0x%02X", xlrec->ntuples,
158  xlrec->flags);
159  }
160  else if (info == XLOG_HEAP2_LOCK_UPDATED)
161  {
163 
164  appendStringInfo(buf, "off %u: xmax %u: flags 0x%02X ",
165  xlrec->offnum, xlrec->xmax, xlrec->flags);
166  out_infobits(buf, xlrec->infobits_set);
167  }
168  else if (info == XLOG_HEAP2_NEW_CID)
169  {
170  xl_heap_new_cid *xlrec = (xl_heap_new_cid *) rec;
171 
172  appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
173  xlrec->target_node.spcNode,
174  xlrec->target_node.dbNode,
175  xlrec->target_node.relNode,
178  appendStringInfo(buf, "; cmin: %u, cmax: %u, combo: %u",
179  xlrec->cmin, xlrec->cmax, xlrec->combocid);
180  }
181 }
unsigned char uint8
Definition: c.h:439
#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
#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
static void out_infobits(StringInfo buf, uint8 infobits)
Definition: heapdesc.c:20
#define ItemPointerGetBlockNumber(pointer)
Definition: itemptr.h:98
#define ItemPointerGetOffsetNumber(pointer)
Definition: itemptr.h:117
static char * buf
Definition: pg_test_fsync.c:70
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
TransactionId cutoff_xid
Definition: heapam_xlog.h:341
TransactionId xmax
Definition: heapam_xlog.h:291
OffsetNumber offnum
Definition: heapam_xlog.h:292
CommandId cmin
Definition: heapam_xlog.h:368
CommandId combocid
Definition: heapam_xlog.h:370
RelFileNode target_node
Definition: heapam_xlog.h:375
ItemPointerData target_tid
Definition: heapam_xlog.h:376
CommandId cmax
Definition: heapam_xlog.h:369
TransactionId latestRemovedXid
Definition: heapam_xlog.h:245
uint16 nredirected
Definition: heapam_xlog.h:246
TransactionId cutoff_xid
Definition: heapam_xlog.h:355
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:315
#define XLogRecGetData(decoder)
Definition: xlogreader.h:320
#define XLR_INFO_MASK
Definition: xlogrecord.h:62

References appendStringInfo(), buf, xl_heap_new_cid::cmax, xl_heap_new_cid::cmin, xl_heap_new_cid::combocid, xl_heap_freeze_page::cutoff_xid, xl_heap_visible::cutoff_xid, RelFileNode::dbNode, xl_heap_multi_insert::flags, xl_heap_lock_updated::flags, xl_heap_visible::flags, xl_heap_lock_updated::infobits_set, ItemPointerGetBlockNumber, ItemPointerGetOffsetNumber, xl_heap_prune::latestRemovedXid, xl_heap_prune::ndead, xl_heap_prune::nredirected, xl_heap_multi_insert::ntuples, xl_heap_freeze_page::ntuples, xl_heap_vacuum::nunused, xl_heap_lock_updated::offnum, out_infobits(), RelFileNode::relNode, RelFileNode::spcNode, xl_heap_new_cid::target_node, 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_OPMASK, XLogRecGetData, XLogRecGetInfo, XLR_INFO_MASK, and xl_heap_lock_updated::xmax.

◆ heap2_identify()

const char* heap2_identify ( uint8  info)

Definition at line 229 of file heapdesc.c.

230 {
231  const char *id = NULL;
232 
233  switch (info & ~XLR_INFO_MASK)
234  {
235  case XLOG_HEAP2_PRUNE:
236  id = "PRUNE";
237  break;
238  case XLOG_HEAP2_VACUUM:
239  id = "VACUUM";
240  break;
242  id = "FREEZE_PAGE";
243  break;
244  case XLOG_HEAP2_VISIBLE:
245  id = "VISIBLE";
246  break;
248  id = "MULTI_INSERT";
249  break;
251  id = "MULTI_INSERT+INIT";
252  break;
254  id = "LOCK_UPDATED";
255  break;
256  case XLOG_HEAP2_NEW_CID:
257  id = "NEW_CID";
258  break;
259  case XLOG_HEAP2_REWRITE:
260  id = "REWRITE";
261  break;
262  }
263 
264  return id;
265 }
#define XLOG_HEAP2_REWRITE
Definition: heapam_xlog.h:53
#define XLOG_HEAP_INIT_PAGE
Definition: heapam_xlog.h:46

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.

◆ heap_desc()

void heap_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 35 of file heapdesc.c.

36 {
37  char *rec = XLogRecGetData(record);
38  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
39 
40  info &= XLOG_HEAP_OPMASK;
41  if (info == XLOG_HEAP_INSERT)
42  {
43  xl_heap_insert *xlrec = (xl_heap_insert *) rec;
44 
45  appendStringInfo(buf, "off %u flags 0x%02X", xlrec->offnum,
46  xlrec->flags);
47  }
48  else if (info == XLOG_HEAP_DELETE)
49  {
50  xl_heap_delete *xlrec = (xl_heap_delete *) rec;
51 
52  appendStringInfo(buf, "off %u flags 0x%02X ",
53  xlrec->offnum,
54  xlrec->flags);
55  out_infobits(buf, xlrec->infobits_set);
56  }
57  else if (info == XLOG_HEAP_UPDATE)
58  {
59  xl_heap_update *xlrec = (xl_heap_update *) rec;
60 
61  appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
62  xlrec->old_offnum,
63  xlrec->old_xmax,
64  xlrec->flags);
66  appendStringInfo(buf, "; new off %u xmax %u",
67  xlrec->new_offnum,
68  xlrec->new_xmax);
69  }
70  else if (info == XLOG_HEAP_HOT_UPDATE)
71  {
72  xl_heap_update *xlrec = (xl_heap_update *) rec;
73 
74  appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
75  xlrec->old_offnum,
76  xlrec->old_xmax,
77  xlrec->flags);
79  appendStringInfo(buf, "; new off %u xmax %u",
80  xlrec->new_offnum,
81  xlrec->new_xmax);
82  }
83  else if (info == XLOG_HEAP_TRUNCATE)
84  {
85  xl_heap_truncate *xlrec = (xl_heap_truncate *) rec;
86  int i;
87 
88  if (xlrec->flags & XLH_TRUNCATE_CASCADE)
89  appendStringInfoString(buf, "cascade ");
90  if (xlrec->flags & XLH_TRUNCATE_RESTART_SEQS)
91  appendStringInfoString(buf, "restart_seqs ");
92  appendStringInfo(buf, "nrelids %u relids", xlrec->nrelids);
93  for (i = 0; i < xlrec->nrelids; i++)
94  appendStringInfo(buf, " %u", xlrec->relids[i]);
95  }
96  else if (info == XLOG_HEAP_CONFIRM)
97  {
98  xl_heap_confirm *xlrec = (xl_heap_confirm *) rec;
99 
100  appendStringInfo(buf, "off %u", xlrec->offnum);
101  }
102  else if (info == XLOG_HEAP_LOCK)
103  {
104  xl_heap_lock *xlrec = (xl_heap_lock *) rec;
105 
106  appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
107  xlrec->offnum, xlrec->locking_xid, xlrec->flags);
108  out_infobits(buf, xlrec->infobits_set);
109  }
110  else if (info == XLOG_HEAP_INPLACE)
111  {
112  xl_heap_inplace *xlrec = (xl_heap_inplace *) rec;
113 
114  appendStringInfo(buf, "off %u", xlrec->offnum);
115  }
116 }
#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 XLH_TRUNCATE_RESTART_SEQS
Definition: heapam_xlog.h:121
#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 XLH_TRUNCATE_CASCADE
Definition: heapam_xlog.h:120
#define XLOG_HEAP_INSERT
Definition: heapam_xlog.h:32
#define XLOG_HEAP_CONFIRM
Definition: heapam_xlog.h:37
int i
Definition: isn.c:73
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
OffsetNumber offnum
Definition: heapam_xlog.h:302
OffsetNumber offnum
Definition: heapam_xlog.h:110
uint8 infobits_set
Definition: heapam_xlog.h:111
OffsetNumber offnum
Definition: heapam_xlog.h:310
OffsetNumber offnum
Definition: heapam_xlog.h:156
OffsetNumber offnum
Definition: heapam_xlog.h:281
int8 infobits_set
Definition: heapam_xlog.h:282
TransactionId locking_xid
Definition: heapam_xlog.h:280
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(), buf, xl_heap_delete::flags, xl_heap_truncate::flags, xl_heap_insert::flags, xl_heap_update::flags, xl_heap_lock::flags, i, xl_heap_delete::infobits_set, xl_heap_lock::infobits_set, xl_heap_lock::locking_xid, 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, xl_heap_update::old_infobits_set, xl_heap_update::old_offnum, xl_heap_update::old_xmax, out_infobits(), xl_heap_truncate::relids, XLH_TRUNCATE_CASCADE, XLH_TRUNCATE_RESTART_SEQS, 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, and XLR_INFO_MASK.

◆ heap_identify()

const char* heap_identify ( uint8  info)

Definition at line 184 of file heapdesc.c.

185 {
186  const char *id = NULL;
187 
188  switch (info & ~XLR_INFO_MASK)
189  {
190  case XLOG_HEAP_INSERT:
191  id = "INSERT";
192  break;
194  id = "INSERT+INIT";
195  break;
196  case XLOG_HEAP_DELETE:
197  id = "DELETE";
198  break;
199  case XLOG_HEAP_UPDATE:
200  id = "UPDATE";
201  break;
203  id = "UPDATE+INIT";
204  break;
206  id = "HOT_UPDATE";
207  break;
209  id = "HOT_UPDATE+INIT";
210  break;
211  case XLOG_HEAP_TRUNCATE:
212  id = "TRUNCATE";
213  break;
214  case XLOG_HEAP_CONFIRM:
215  id = "HEAP_CONFIRM";
216  break;
217  case XLOG_HEAP_LOCK:
218  id = "LOCK";
219  break;
220  case XLOG_HEAP_INPLACE:
221  id = "INPLACE";
222  break;
223  }
224 
225  return id;
226 }

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.

◆ out_infobits()

static void out_infobits ( StringInfo  buf,
uint8  infobits 
)
static

Definition at line 20 of file heapdesc.c.

21 {
22  if (infobits & XLHL_XMAX_IS_MULTI)
23  appendStringInfoString(buf, "IS_MULTI ");
24  if (infobits & XLHL_XMAX_LOCK_ONLY)
25  appendStringInfoString(buf, "LOCK_ONLY ");
26  if (infobits & XLHL_XMAX_EXCL_LOCK)
27  appendStringInfoString(buf, "EXCL_LOCK ");
28  if (infobits & XLHL_XMAX_KEYSHR_LOCK)
29  appendStringInfoString(buf, "KEYSHR_LOCK ");
30  if (infobits & XLHL_KEYS_UPDATED)
31  appendStringInfoString(buf, "KEYS_UPDATED ");
32 }
#define XLHL_XMAX_KEYSHR_LOCK
Definition: heapam_xlog.h:271
#define XLHL_XMAX_IS_MULTI
Definition: heapam_xlog.h:268
#define XLHL_XMAX_LOCK_ONLY
Definition: heapam_xlog.h:269
#define XLHL_XMAX_EXCL_LOCK
Definition: heapam_xlog.h:270
#define XLHL_KEYS_UPDATED
Definition: heapam_xlog.h:272

References appendStringInfoString(), buf, XLHL_KEYS_UPDATED, XLHL_XMAX_EXCL_LOCK, XLHL_XMAX_IS_MULTI, XLHL_XMAX_KEYSHR_LOCK, and XLHL_XMAX_LOCK_ONLY.

Referenced by heap2_desc(), and heap_desc().