PostgreSQL Source Code  git master
spgdesc.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * spgdesc.c
4  * rmgr descriptor routines for access/spgist/spgxlog.c
5  *
6  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  * src/backend/access/rmgrdesc/spgdesc.c
12  *
13  *-------------------------------------------------------------------------
14  */
15 #include "postgres.h"
16 
17 #include "access/spgxlog.h"
18 
19 void
21 {
22  char *rec = XLogRecGetData(record);
23  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
24 
25  switch (info)
26  {
28  {
29  spgxlogAddLeaf *xlrec = (spgxlogAddLeaf *) rec;
30 
31  appendStringInfoString(buf, "add leaf to page");
32  appendStringInfo(buf, "; off %u; headoff %u; parentoff %u",
33  xlrec->offnumLeaf, xlrec->offnumHeadLeaf,
34  xlrec->offnumParent);
35  if (xlrec->newPage)
36  appendStringInfoString(buf, " (newpage)");
37  if (xlrec->storesNulls)
38  appendStringInfoString(buf, " (nulls)");
39  }
40  break;
42  appendStringInfo(buf, "%u leafs",
43  ((spgxlogMoveLeafs *) rec)->nMoves);
44  break;
46  appendStringInfo(buf, "off %u",
47  ((spgxlogAddNode *) rec)->offnum);
48  break;
50  appendStringInfo(buf, "prefix off: %u, postfix off: %u (same %d, new %d)",
51  ((spgxlogSplitTuple *) rec)->offnumPrefix,
52  ((spgxlogSplitTuple *) rec)->offnumPostfix,
53  ((spgxlogSplitTuple *) rec)->postfixBlkSame,
54  ((spgxlogSplitTuple *) rec)->newPage
55  );
56  break;
58  {
59  spgxlogPickSplit *xlrec = (spgxlogPickSplit *) rec;
60 
61  appendStringInfo(buf, "ndel %u; nins %u",
62  xlrec->nDelete, xlrec->nInsert);
63  if (xlrec->innerIsParent)
64  appendStringInfoString(buf, " (innerIsParent)");
65  if (xlrec->isRootSplit)
66  appendStringInfoString(buf, " (isRootSplit)");
67  }
68  break;
70  /* no further information */
71  break;
73  /* no further information */
74  break;
76  appendStringInfo(buf, "newest XID %u",
77  ((spgxlogVacuumRedirect *) rec)->newestRedirectXid);
78  break;
79  }
80 }
81 
82 const char *
84 {
85  const char *id = NULL;
86 
87  switch (info & ~XLR_INFO_MASK)
88  {
90  id = "ADD_LEAF";
91  break;
93  id = "MOVE_LEAFS";
94  break;
96  id = "ADD_NODE";
97  break;
99  id = "SPLIT_TUPLE";
100  break;
102  id = "PICKSPLIT";
103  break;
105  id = "VACUUM_LEAF";
106  break;
108  id = "VACUUM_ROOT";
109  break;
111  id = "VACUUM_REDIRECT";
112  break;
113  }
114 
115  return id;
116 }
void spg_desc(StringInfo buf, XLogReaderState *record)
Definition: spgdesc.c:20
#define XLOG_SPGIST_MOVE_LEAFS
Definition: spgxlog.h:23
#define XLOG_SPGIST_VACUUM_REDIRECT
Definition: spgxlog.h:29
uint16 nDelete
Definition: spgxlog.h:169
OffsetNumber offnumParent
Definition: spgxlog.h:53
#define XLOG_SPGIST_SPLIT_TUPLE
Definition: spgxlog.h:25
OffsetNumber offnumLeaf
Definition: spgxlog.h:50
unsigned char uint8
Definition: c.h:356
#define XLOG_SPGIST_ADD_NODE
Definition: spgxlog.h:24
#define XLOG_SPGIST_ADD_LEAF
Definition: spgxlog.h:22
uint16 nInsert
Definition: spgxlog.h:170
bool innerIsParent
Definition: spgxlog.h:181
#define XLOG_SPGIST_PICKSPLIT
Definition: spgxlog.h:26
#define XLOG_SPGIST_VACUUM_ROOT
Definition: spgxlog.h:28
#define XLogRecGetData(decoder)
Definition: xlogreader.h:246
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:78
bool newPage
Definition: spgxlog.h:48
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:163
static char * buf
Definition: pg_test_fsync.c:68
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:242
OffsetNumber offnumHeadLeaf
Definition: spgxlog.h:51
bool storesNulls
Definition: spgxlog.h:49
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_SPGIST_VACUUM_LEAF
Definition: spgxlog.h:27
const char * spg_identify(uint8 info)
Definition: spgdesc.c:83
bool isRootSplit
Definition: spgxlog.h:167