PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
nbtdesc.c File Reference
#include "postgres.h"
#include "access/nbtxlog.h"
#include "access/rmgrdesc_utils.h"
Include dependency graph for nbtdesc.c:

Go to the source code of this file.

Functions

static void delvacuum_desc (StringInfo buf, char *block_data, uint16 ndeleted, uint16 nupdated)
 
void btree_desc (StringInfo buf, XLogReaderState *record)
 
const char * btree_identify (uint8 info)
 

Function Documentation

◆ btree_desc()

void btree_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 24 of file nbtdesc.c.

25 {
26  char *rec = XLogRecGetData(record);
27  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
28 
29  switch (info)
30  {
35  {
36  xl_btree_insert *xlrec = (xl_btree_insert *) rec;
37 
38  appendStringInfo(buf, "off: %u", xlrec->offnum);
39  break;
40  }
41  case XLOG_BTREE_SPLIT_L:
42  case XLOG_BTREE_SPLIT_R:
43  {
44  xl_btree_split *xlrec = (xl_btree_split *) rec;
45 
46  appendStringInfo(buf, "level: %u, firstrightoff: %d, newitemoff: %d, postingoff: %d",
47  xlrec->level, xlrec->firstrightoff,
48  xlrec->newitemoff, xlrec->postingoff);
49  break;
50  }
51  case XLOG_BTREE_DEDUP:
52  {
53  xl_btree_dedup *xlrec = (xl_btree_dedup *) rec;
54 
55  appendStringInfo(buf, "nintervals: %u", xlrec->nintervals);
56  break;
57  }
58  case XLOG_BTREE_VACUUM:
59  {
60  xl_btree_vacuum *xlrec = (xl_btree_vacuum *) rec;
61 
62  appendStringInfo(buf, "ndeleted: %u, nupdated: %u",
63  xlrec->ndeleted, xlrec->nupdated);
64 
65  if (XLogRecHasBlockData(record, 0))
66  delvacuum_desc(buf, XLogRecGetBlockData(record, 0, NULL),
67  xlrec->ndeleted, xlrec->nupdated);
68  break;
69  }
70  case XLOG_BTREE_DELETE:
71  {
72  xl_btree_delete *xlrec = (xl_btree_delete *) rec;
73 
74  appendStringInfo(buf, "snapshotConflictHorizon: %u, ndeleted: %u, nupdated: %u, isCatalogRel: %c",
76  xlrec->ndeleted, xlrec->nupdated,
77  xlrec->isCatalogRel ? 'T' : 'F');
78 
79  if (XLogRecHasBlockData(record, 0))
80  delvacuum_desc(buf, XLogRecGetBlockData(record, 0, NULL),
81  xlrec->ndeleted, xlrec->nupdated);
82  break;
83  }
85  {
87 
88  appendStringInfo(buf, "topparent: %u, leaf: %u, left: %u, right: %u",
89  xlrec->topparent, xlrec->leafblk, xlrec->leftblk, xlrec->rightblk);
90  break;
91  }
94  {
96 
97  appendStringInfo(buf, "left: %u, right: %u, level: %u, safexid: %u:%u, ",
98  xlrec->leftsib, xlrec->rightsib, xlrec->level,
101  appendStringInfo(buf, "leafleft: %u, leafright: %u, leaftopparent: %u",
102  xlrec->leafleftsib, xlrec->leafrightsib,
103  xlrec->leaftopparent);
104  break;
105  }
106  case XLOG_BTREE_NEWROOT:
107  {
108  xl_btree_newroot *xlrec = (xl_btree_newroot *) rec;
109 
110  appendStringInfo(buf, "level: %u", xlrec->level);
111  break;
112  }
114  {
115  xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
116 
117  appendStringInfo(buf, "rel: %u/%u/%u, snapshotConflictHorizon: %u:%u, isCatalogRel: %c",
118  xlrec->locator.spcOid, xlrec->locator.dbOid,
119  xlrec->locator.relNumber,
122  xlrec->isCatalogRel ? 'T' : 'F');
123  break;
124  }
126  {
127  xl_btree_metadata *xlrec;
128 
129  xlrec = (xl_btree_metadata *) XLogRecGetBlockData(record, 0,
130  NULL);
131  appendStringInfo(buf, "last_cleanup_num_delpages: %u",
133  break;
134  }
135  }
136 }
unsigned char uint8
Definition: c.h:516
static void delvacuum_desc(StringInfo buf, char *block_data, uint16 ndeleted, uint16 nupdated)
Definition: nbtdesc.c:196
#define XLOG_BTREE_META_CLEANUP
Definition: nbtxlog.h:41
#define XLOG_BTREE_INSERT_POST
Definition: nbtxlog.h:32
#define XLOG_BTREE_VACUUM
Definition: nbtxlog.h:39
#define XLOG_BTREE_SPLIT_R
Definition: nbtxlog.h:31
#define XLOG_BTREE_INSERT_LEAF
Definition: nbtxlog.h:27
#define XLOG_BTREE_INSERT_UPPER
Definition: nbtxlog.h:28
#define XLOG_BTREE_DEDUP
Definition: nbtxlog.h:33
#define XLOG_BTREE_UNLINK_PAGE
Definition: nbtxlog.h:35
#define XLOG_BTREE_UNLINK_PAGE_META
Definition: nbtxlog.h:36
#define XLOG_BTREE_INSERT_META
Definition: nbtxlog.h:29
#define XLOG_BTREE_MARK_PAGE_HALFDEAD
Definition: nbtxlog.h:38
#define XLOG_BTREE_REUSE_PAGE
Definition: nbtxlog.h:40
#define XLOG_BTREE_SPLIT_L
Definition: nbtxlog.h:30
#define XLOG_BTREE_NEWROOT
Definition: nbtxlog.h:37
#define XLOG_BTREE_DELETE
Definition: nbtxlog.h:34
static char * buf
Definition: pg_test_fsync.c:72
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:94
RelFileNumber relNumber
uint16 nintervals
Definition: nbtxlog.h:169
TransactionId snapshotConflictHorizon
Definition: nbtxlog.h:238
bool isCatalogRel
Definition: nbtxlog.h:241
uint16 ndeleted
Definition: nbtxlog.h:239
uint16 nupdated
Definition: nbtxlog.h:240
OffsetNumber offnum
Definition: nbtxlog.h:78
uint32 last_cleanup_num_delpages
Definition: nbtxlog.h:53
uint32 level
Definition: nbtxlog.h:344
FullTransactionId snapshotConflictHorizon
Definition: nbtxlog.h:187
RelFileLocator locator
Definition: nbtxlog.h:185
uint16 postingoff
Definition: nbtxlog.h:155
OffsetNumber firstrightoff
Definition: nbtxlog.h:153
uint32 level
Definition: nbtxlog.h:152
OffsetNumber newitemoff
Definition: nbtxlog.h:154
uint16 ndeleted
Definition: nbtxlog.h:222
uint16 nupdated
Definition: nbtxlog.h:223
#define EpochFromFullTransactionId(x)
Definition: transam.h:47
#define XidFromFullTransactionId(x)
Definition: transam.h:48
char * XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len)
Definition: xlogreader.c:2025
#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(), buf, RelFileLocator::dbOid, delvacuum_desc(), EpochFromFullTransactionId, xl_btree_split::firstrightoff, xl_btree_reuse_page::isCatalogRel, xl_btree_delete::isCatalogRel, xl_btree_metadata::last_cleanup_num_delpages, xl_btree_mark_page_halfdead::leafblk, xl_btree_unlink_page::leafleftsib, xl_btree_unlink_page::leafrightsib, xl_btree_unlink_page::leaftopparent, xl_btree_mark_page_halfdead::leftblk, xl_btree_unlink_page::leftsib, xl_btree_split::level, xl_btree_unlink_page::level, xl_btree_newroot::level, xl_btree_reuse_page::locator, xl_btree_vacuum::ndeleted, xl_btree_delete::ndeleted, xl_btree_split::newitemoff, xl_btree_dedup::nintervals, xl_btree_vacuum::nupdated, xl_btree_delete::nupdated, xl_btree_insert::offnum, xl_btree_split::postingoff, RelFileLocator::relNumber, xl_btree_mark_page_halfdead::rightblk, xl_btree_unlink_page::rightsib, xl_btree_unlink_page::safexid, xl_btree_reuse_page::snapshotConflictHorizon, xl_btree_delete::snapshotConflictHorizon, RelFileLocator::spcOid, xl_btree_mark_page_halfdead::topparent, XidFromFullTransactionId, XLOG_BTREE_DEDUP, XLOG_BTREE_DELETE, XLOG_BTREE_INSERT_LEAF, XLOG_BTREE_INSERT_META, XLOG_BTREE_INSERT_POST, XLOG_BTREE_INSERT_UPPER, XLOG_BTREE_MARK_PAGE_HALFDEAD, XLOG_BTREE_META_CLEANUP, XLOG_BTREE_NEWROOT, XLOG_BTREE_REUSE_PAGE, XLOG_BTREE_SPLIT_L, XLOG_BTREE_SPLIT_R, XLOG_BTREE_UNLINK_PAGE, XLOG_BTREE_UNLINK_PAGE_META, XLOG_BTREE_VACUUM, XLogRecGetBlockData(), XLogRecGetData, XLogRecGetInfo, XLogRecHasBlockData, and XLR_INFO_MASK.

◆ btree_identify()

const char* btree_identify ( uint8  info)

Definition at line 139 of file nbtdesc.c.

140 {
141  const char *id = NULL;
142 
143  switch (info & ~XLR_INFO_MASK)
144  {
146  id = "INSERT_LEAF";
147  break;
149  id = "INSERT_UPPER";
150  break;
152  id = "INSERT_META";
153  break;
154  case XLOG_BTREE_SPLIT_L:
155  id = "SPLIT_L";
156  break;
157  case XLOG_BTREE_SPLIT_R:
158  id = "SPLIT_R";
159  break;
161  id = "INSERT_POST";
162  break;
163  case XLOG_BTREE_DEDUP:
164  id = "DEDUP";
165  break;
166  case XLOG_BTREE_VACUUM:
167  id = "VACUUM";
168  break;
169  case XLOG_BTREE_DELETE:
170  id = "DELETE";
171  break;
173  id = "MARK_PAGE_HALFDEAD";
174  break;
176  id = "UNLINK_PAGE";
177  break;
179  id = "UNLINK_PAGE_META";
180  break;
181  case XLOG_BTREE_NEWROOT:
182  id = "NEWROOT";
183  break;
185  id = "REUSE_PAGE";
186  break;
188  id = "META_CLEANUP";
189  break;
190  }
191 
192  return id;
193 }

References XLOG_BTREE_DEDUP, XLOG_BTREE_DELETE, XLOG_BTREE_INSERT_LEAF, XLOG_BTREE_INSERT_META, XLOG_BTREE_INSERT_POST, XLOG_BTREE_INSERT_UPPER, XLOG_BTREE_MARK_PAGE_HALFDEAD, XLOG_BTREE_META_CLEANUP, XLOG_BTREE_NEWROOT, XLOG_BTREE_REUSE_PAGE, XLOG_BTREE_SPLIT_L, XLOG_BTREE_SPLIT_R, XLOG_BTREE_UNLINK_PAGE, XLOG_BTREE_UNLINK_PAGE_META, XLOG_BTREE_VACUUM, and XLR_INFO_MASK.

◆ delvacuum_desc()

static void delvacuum_desc ( StringInfo  buf,
char *  block_data,
uint16  ndeleted,
uint16  nupdated 
)
static

Definition at line 196 of file nbtdesc.c.

198 {
199  OffsetNumber *deletedoffsets;
200  OffsetNumber *updatedoffsets;
201  xl_btree_update *updates;
202 
203  /* Output deleted page offset number array */
204  appendStringInfoString(buf, ", deleted:");
205  deletedoffsets = (OffsetNumber *) block_data;
206  array_desc(buf, deletedoffsets, sizeof(OffsetNumber), ndeleted,
207  &offset_elem_desc, NULL);
208 
209  /*
210  * Output updates as an array of "update objects", where each element
211  * contains a page offset number from updated array. (This is not the
212  * most literal representation of the underlying physical data structure
213  * that we could use. Readability seems more important here.)
214  */
215  appendStringInfoString(buf, ", updated: [");
216  updatedoffsets = (OffsetNumber *) (block_data + ndeleted *
217  sizeof(OffsetNumber));
218  updates = (xl_btree_update *) ((char *) updatedoffsets +
219  nupdated *
220  sizeof(OffsetNumber));
221  for (int i = 0; i < nupdated; i++)
222  {
223  OffsetNumber off = updatedoffsets[i];
224 
226  Assert(updates->ndeletedtids > 0);
227 
228  /*
229  * "ptid" is the symbol name used when building each xl_btree_update's
230  * array of offsets into a posting list tuple's ItemPointerData array.
231  * xl_btree_update describes a subset of the existing TIDs to delete.
232  */
233  appendStringInfo(buf, "{ off: %u, nptids: %u, ptids: [",
234  off, updates->ndeletedtids);
235  for (int p = 0; p < updates->ndeletedtids; p++)
236  {
237  uint16 *ptid;
238 
239  ptid = (uint16 *) ((char *) updates + SizeOfBtreeUpdate) + p;
240  appendStringInfo(buf, "%u", *ptid);
241 
242  if (p < updates->ndeletedtids - 1)
244  }
245  appendStringInfoString(buf, "] }");
246  if (i < nupdated - 1)
248 
249  updates = (xl_btree_update *)
250  ((char *) updates + SizeOfBtreeUpdate +
251  updates->ndeletedtids * sizeof(uint16));
252  }
254 }
unsigned short uint16
Definition: c.h:517
#define Assert(condition)
Definition: c.h:863
int i
Definition: isn.c:72
#define SizeOfBtreeUpdate
Definition: nbtxlog.h:268
#define OffsetNumberIsValid(offsetNumber)
Definition: off.h:39
uint16 OffsetNumber
Definition: off.h:24
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 appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:179
void appendStringInfoChar(StringInfo str, char ch)
Definition: stringinfo.c:191
uint16 ndeletedtids
Definition: nbtxlog.h:263

References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), array_desc(), Assert, buf, i, xl_btree_update::ndeletedtids, offset_elem_desc(), OffsetNumberIsValid, and SizeOfBtreeUpdate.

Referenced by btree_desc().