PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
spgxlog.h File Reference
#include "access/xlogreader.h"
#include "lib/stringinfo.h"
#include "storage/off.h"
Include dependency graph for spgxlog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  spgxlogState
 
struct  spgxlogAddLeaf
 
struct  spgxlogMoveLeafs
 
struct  spgxlogAddNode
 
struct  spgxlogSplitTuple
 
struct  spgxlogPickSplit
 
struct  spgxlogVacuumLeaf
 
struct  spgxlogVacuumRoot
 
struct  spgxlogVacuumRedirect
 

Macros

#define XLOG_SPGIST_ADD_LEAF   0x10
 
#define XLOG_SPGIST_MOVE_LEAFS   0x20
 
#define XLOG_SPGIST_ADD_NODE   0x30
 
#define XLOG_SPGIST_SPLIT_TUPLE   0x40
 
#define XLOG_SPGIST_PICKSPLIT   0x50
 
#define XLOG_SPGIST_VACUUM_LEAF   0x60
 
#define XLOG_SPGIST_VACUUM_ROOT   0x70
 
#define XLOG_SPGIST_VACUUM_REDIRECT   0x80
 
#define SizeOfSpgxlogMoveLeafs   offsetof(spgxlogMoveLeafs, offsets)
 
#define SizeOfSpgxlogPickSplit   offsetof(spgxlogPickSplit, offsets)
 
#define SizeOfSpgxlogVacuumLeaf   offsetof(spgxlogVacuumLeaf, offsets)
 
#define SizeOfSpgxlogVacuumRoot   offsetof(spgxlogVacuumRoot, offsets)
 
#define SizeOfSpgxlogVacuumRedirect   offsetof(spgxlogVacuumRedirect, offsets)
 

Typedefs

typedef struct spgxlogState spgxlogState
 
typedef struct spgxlogAddLeaf spgxlogAddLeaf
 
typedef struct spgxlogMoveLeafs spgxlogMoveLeafs
 
typedef struct spgxlogAddNode spgxlogAddNode
 
typedef struct spgxlogSplitTuple spgxlogSplitTuple
 
typedef struct spgxlogPickSplit spgxlogPickSplit
 
typedef struct spgxlogVacuumLeaf spgxlogVacuumLeaf
 
typedef struct spgxlogVacuumRoot spgxlogVacuumRoot
 
typedef struct spgxlogVacuumRedirect spgxlogVacuumRedirect
 

Functions

void spg_redo (XLogReaderState *record)
 
void spg_desc (StringInfo buf, XLogReaderState *record)
 
const char * spg_identify (uint8 info)
 
void spg_xlog_startup (void)
 
void spg_xlog_cleanup (void)
 
void spg_mask (char *pagedata, BlockNumber blkno)
 

Macro Definition Documentation

◆ SizeOfSpgxlogMoveLeafs

#define SizeOfSpgxlogMoveLeafs   offsetof(spgxlogMoveLeafs, offsets)

Definition at line 91 of file spgxlog.h.

◆ SizeOfSpgxlogPickSplit

#define SizeOfSpgxlogPickSplit   offsetof(spgxlogPickSplit, offsets)

Definition at line 199 of file spgxlog.h.

◆ SizeOfSpgxlogVacuumLeaf

#define SizeOfSpgxlogVacuumLeaf   offsetof(spgxlogVacuumLeaf, offsets)

Definition at line 223 of file spgxlog.h.

◆ SizeOfSpgxlogVacuumRedirect

#define SizeOfSpgxlogVacuumRedirect   offsetof(spgxlogVacuumRedirect, offsets)

Definition at line 250 of file spgxlog.h.

◆ SizeOfSpgxlogVacuumRoot

#define SizeOfSpgxlogVacuumRoot   offsetof(spgxlogVacuumRoot, offsets)

Definition at line 236 of file spgxlog.h.

◆ XLOG_SPGIST_ADD_LEAF

#define XLOG_SPGIST_ADD_LEAF   0x10

Definition at line 22 of file spgxlog.h.

◆ XLOG_SPGIST_ADD_NODE

#define XLOG_SPGIST_ADD_NODE   0x30

Definition at line 24 of file spgxlog.h.

◆ XLOG_SPGIST_MOVE_LEAFS

#define XLOG_SPGIST_MOVE_LEAFS   0x20

Definition at line 23 of file spgxlog.h.

◆ XLOG_SPGIST_PICKSPLIT

#define XLOG_SPGIST_PICKSPLIT   0x50

Definition at line 26 of file spgxlog.h.

◆ XLOG_SPGIST_SPLIT_TUPLE

#define XLOG_SPGIST_SPLIT_TUPLE   0x40

Definition at line 25 of file spgxlog.h.

◆ XLOG_SPGIST_VACUUM_LEAF

#define XLOG_SPGIST_VACUUM_LEAF   0x60

Definition at line 27 of file spgxlog.h.

◆ XLOG_SPGIST_VACUUM_REDIRECT

#define XLOG_SPGIST_VACUUM_REDIRECT   0x80

Definition at line 29 of file spgxlog.h.

◆ XLOG_SPGIST_VACUUM_ROOT

#define XLOG_SPGIST_VACUUM_ROOT   0x70

Definition at line 28 of file spgxlog.h.

Typedef Documentation

◆ spgxlogAddLeaf

◆ spgxlogAddNode

◆ spgxlogMoveLeafs

◆ spgxlogPickSplit

◆ spgxlogSplitTuple

◆ spgxlogState

typedef struct spgxlogState spgxlogState

◆ spgxlogVacuumLeaf

◆ spgxlogVacuumRedirect

◆ spgxlogVacuumRoot

Function Documentation

◆ spg_desc()

void spg_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 20 of file spgdesc.c.

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  appendStringInfo(buf, "off: %u, headoff: %u, parentoff: %u, nodeI: %u",
32  xlrec->offnumLeaf, xlrec->offnumHeadLeaf,
33  xlrec->offnumParent, xlrec->nodeI);
34  if (xlrec->newPage)
35  appendStringInfoString(buf, " (newpage)");
36  if (xlrec->storesNulls)
37  appendStringInfoString(buf, " (nulls)");
38  }
39  break;
41  {
42  spgxlogMoveLeafs *xlrec = (spgxlogMoveLeafs *) rec;
43 
44  appendStringInfo(buf, "nmoves: %u, parentoff: %u, nodeI: %u",
45  xlrec->nMoves,
46  xlrec->offnumParent, xlrec->nodeI);
47  if (xlrec->newPage)
48  appendStringInfoString(buf, " (newpage)");
49  if (xlrec->replaceDead)
50  appendStringInfoString(buf, " (replacedead)");
51  if (xlrec->storesNulls)
52  appendStringInfoString(buf, " (nulls)");
53  }
54  break;
56  {
57  spgxlogAddNode *xlrec = (spgxlogAddNode *) rec;
58 
59  appendStringInfo(buf, "off: %u, newoff: %u, parentBlk: %d, "
60  "parentoff: %u, nodeI: %u",
61  xlrec->offnum,
62  xlrec->offnumNew,
63  xlrec->parentBlk,
64  xlrec->offnumParent,
65  xlrec->nodeI);
66  if (xlrec->newPage)
67  appendStringInfoString(buf, " (newpage)");
68  }
69  break;
71  {
72  spgxlogSplitTuple *xlrec = (spgxlogSplitTuple *) rec;
73 
74  appendStringInfo(buf, "prefixoff: %u, postfixoff: %u",
75  xlrec->offnumPrefix,
76  xlrec->offnumPostfix);
77  if (xlrec->newPage)
78  appendStringInfoString(buf, " (newpage)");
79  if (xlrec->postfixBlkSame)
80  appendStringInfoString(buf, " (same)");
81  }
82  break;
84  {
85  spgxlogPickSplit *xlrec = (spgxlogPickSplit *) rec;
86 
87  appendStringInfo(buf, "ndelete: %u, ninsert: %u, inneroff: %u, "
88  "parentoff: %u, nodeI: %u",
89  xlrec->nDelete, xlrec->nInsert,
90  xlrec->offnumInner,
91  xlrec->offnumParent, xlrec->nodeI);
92  if (xlrec->innerIsParent)
93  appendStringInfoString(buf, " (innerIsParent)");
94  if (xlrec->storesNulls)
95  appendStringInfoString(buf, " (nulls)");
96  if (xlrec->isRootSplit)
97  appendStringInfoString(buf, " (isRootSplit)");
98  }
99  break;
101  {
102  spgxlogVacuumLeaf *xlrec = (spgxlogVacuumLeaf *) rec;
103 
104  appendStringInfo(buf, "ndead: %u, nplaceholder: %u, nmove: %u, nchain: %u",
105  xlrec->nDead, xlrec->nPlaceholder,
106  xlrec->nMove, xlrec->nChain);
107  }
108  break;
110  {
111  spgxlogVacuumRoot *xlrec = (spgxlogVacuumRoot *) rec;
112 
113  appendStringInfo(buf, "ndelete: %u",
114  xlrec->nDelete);
115  }
116  break;
118  {
120 
121  appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, snapshotConflictHorizon: %u, isCatalogRel: %c",
122  xlrec->nToPlaceholder,
123  xlrec->firstPlaceholder,
125  xlrec->isCatalogRel ? 'T' : 'F');
126  }
127  break;
128  }
129 }
unsigned char uint8
Definition: c.h:516
static char * buf
Definition: pg_test_fsync.c:72
#define XLOG_SPGIST_SPLIT_TUPLE
Definition: spgxlog.h:25
#define XLOG_SPGIST_VACUUM_ROOT
Definition: spgxlog.h:28
#define XLOG_SPGIST_VACUUM_LEAF
Definition: spgxlog.h:27
#define XLOG_SPGIST_ADD_NODE
Definition: spgxlog.h:24
#define XLOG_SPGIST_ADD_LEAF
Definition: spgxlog.h:22
#define XLOG_SPGIST_MOVE_LEAFS
Definition: spgxlog.h:23
#define XLOG_SPGIST_PICKSPLIT
Definition: spgxlog.h:26
#define XLOG_SPGIST_VACUUM_REDIRECT
Definition: spgxlog.h:29
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:94
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:179
uint16 nodeI
Definition: spgxlog.h:54
bool newPage
Definition: spgxlog.h:48
OffsetNumber offnumLeaf
Definition: spgxlog.h:50
bool storesNulls
Definition: spgxlog.h:49
OffsetNumber offnumHeadLeaf
Definition: spgxlog.h:51
OffsetNumber offnumParent
Definition: spgxlog.h:53
OffsetNumber offnumNew
Definition: spgxlog.h:111
bool newPage
Definition: spgxlog.h:112
OffsetNumber offnumParent
Definition: spgxlog.h:126
OffsetNumber offnum
Definition: spgxlog.h:105
uint16 nodeI
Definition: spgxlog.h:128
int8 parentBlk
Definition: spgxlog.h:125
bool replaceDead
Definition: spgxlog.h:68
bool storesNulls
Definition: spgxlog.h:69
uint16 nMoves
Definition: spgxlog.h:66
uint16 nodeI
Definition: spgxlog.h:73
OffsetNumber offnumParent
Definition: spgxlog.h:72
uint16 nInsert
Definition: spgxlog.h:170
bool innerIsParent
Definition: spgxlog.h:181
uint16 nodeI
Definition: spgxlog.h:183
bool storesNulls
Definition: spgxlog.h:178
OffsetNumber offnumParent
Definition: spgxlog.h:182
OffsetNumber offnumInner
Definition: spgxlog.h:175
uint16 nDelete
Definition: spgxlog.h:169
bool isRootSplit
Definition: spgxlog.h:167
OffsetNumber offnumPostfix
Definition: spgxlog.h:147
OffsetNumber offnumPrefix
Definition: spgxlog.h:144
bool postfixBlkSame
Definition: spgxlog.h:149
uint16 nPlaceholder
Definition: spgxlog.h:204
OffsetNumber firstPlaceholder
Definition: spgxlog.h:241
TransactionId snapshotConflictHorizon
Definition: spgxlog.h:242
uint16 nDelete
Definition: spgxlog.h:228
#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(), buf, spgxlogVacuumRedirect::firstPlaceholder, spgxlogPickSplit::innerIsParent, spgxlogVacuumRedirect::isCatalogRel, spgxlogPickSplit::isRootSplit, spgxlogVacuumLeaf::nChain, spgxlogVacuumLeaf::nDead, spgxlogPickSplit::nDelete, spgxlogVacuumRoot::nDelete, spgxlogAddLeaf::newPage, spgxlogMoveLeafs::newPage, spgxlogAddNode::newPage, spgxlogSplitTuple::newPage, spgxlogPickSplit::nInsert, spgxlogVacuumLeaf::nMove, spgxlogMoveLeafs::nMoves, spgxlogAddLeaf::nodeI, spgxlogMoveLeafs::nodeI, spgxlogAddNode::nodeI, spgxlogPickSplit::nodeI, spgxlogVacuumLeaf::nPlaceholder, spgxlogVacuumRedirect::nToPlaceholder, spgxlogAddNode::offnum, spgxlogAddLeaf::offnumHeadLeaf, spgxlogPickSplit::offnumInner, spgxlogAddLeaf::offnumLeaf, spgxlogAddNode::offnumNew, spgxlogAddLeaf::offnumParent, spgxlogMoveLeafs::offnumParent, spgxlogAddNode::offnumParent, spgxlogPickSplit::offnumParent, spgxlogSplitTuple::offnumPostfix, spgxlogSplitTuple::offnumPrefix, spgxlogAddNode::parentBlk, spgxlogSplitTuple::postfixBlkSame, spgxlogMoveLeafs::replaceDead, spgxlogVacuumRedirect::snapshotConflictHorizon, spgxlogAddLeaf::storesNulls, spgxlogMoveLeafs::storesNulls, spgxlogPickSplit::storesNulls, XLOG_SPGIST_ADD_LEAF, XLOG_SPGIST_ADD_NODE, XLOG_SPGIST_MOVE_LEAFS, XLOG_SPGIST_PICKSPLIT, XLOG_SPGIST_SPLIT_TUPLE, XLOG_SPGIST_VACUUM_LEAF, XLOG_SPGIST_VACUUM_REDIRECT, XLOG_SPGIST_VACUUM_ROOT, XLogRecGetData, XLogRecGetInfo, and XLR_INFO_MASK.

◆ spg_identify()

const char* spg_identify ( uint8  info)

Definition at line 132 of file spgdesc.c.

133 {
134  const char *id = NULL;
135 
136  switch (info & ~XLR_INFO_MASK)
137  {
139  id = "ADD_LEAF";
140  break;
142  id = "MOVE_LEAFS";
143  break;
145  id = "ADD_NODE";
146  break;
148  id = "SPLIT_TUPLE";
149  break;
151  id = "PICKSPLIT";
152  break;
154  id = "VACUUM_LEAF";
155  break;
157  id = "VACUUM_ROOT";
158  break;
160  id = "VACUUM_REDIRECT";
161  break;
162  }
163 
164  return id;
165 }

References XLOG_SPGIST_ADD_LEAF, XLOG_SPGIST_ADD_NODE, XLOG_SPGIST_MOVE_LEAFS, XLOG_SPGIST_PICKSPLIT, XLOG_SPGIST_SPLIT_TUPLE, XLOG_SPGIST_VACUUM_LEAF, XLOG_SPGIST_VACUUM_REDIRECT, XLOG_SPGIST_VACUUM_ROOT, and XLR_INFO_MASK.

◆ spg_mask()

void spg_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 994 of file spgxlog.c.

995 {
996  Page page = (Page) pagedata;
997  PageHeader pagehdr = (PageHeader) page;
998 
1000 
1001  mask_page_hint_bits(page);
1002 
1003  /*
1004  * Mask the unused space, but only if the page's pd_lower appears to have
1005  * been set correctly.
1006  */
1007  if (pagehdr->pd_lower >= SizeOfPageHeaderData)
1008  mask_unused_space(page);
1009 }
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
PageHeaderData * PageHeader
Definition: bufpage.h:173
Pointer Page
Definition: bufpage.h:81
#define SizeOfPageHeaderData
Definition: bufpage.h:216
LocationIndex pd_lower
Definition: bufpage.h:165

References mask_page_hint_bits(), mask_page_lsn_and_checksum(), mask_unused_space(), PageHeaderData::pd_lower, and SizeOfPageHeaderData.

◆ spg_redo()

void spg_redo ( XLogReaderState record)

Definition at line 935 of file spgxlog.c.

936 {
937  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
938  MemoryContext oldCxt;
939 
940  oldCxt = MemoryContextSwitchTo(opCtx);
941  switch (info)
942  {
944  spgRedoAddLeaf(record);
945  break;
947  spgRedoMoveLeafs(record);
948  break;
950  spgRedoAddNode(record);
951  break;
953  spgRedoSplitTuple(record);
954  break;
956  spgRedoPickSplit(record);
957  break;
959  spgRedoVacuumLeaf(record);
960  break;
962  spgRedoVacuumRoot(record);
963  break;
965  spgRedoVacuumRedirect(record);
966  break;
967  default:
968  elog(PANIC, "spg_redo: unknown op code %u", info);
969  }
970 
971  MemoryContextSwitchTo(oldCxt);
973 }
#define PANIC
Definition: elog.h:42
#define elog(elevel,...)
Definition: elog.h:225
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:383
MemoryContextSwitchTo(old_ctx)
static void spgRedoVacuumRoot(XLogReaderState *record)
Definition: spgxlog.c:834
static void spgRedoSplitTuple(XLogReaderState *record)
Definition: spgxlog.c:451
static void spgRedoVacuumRedirect(XLogReaderState *record)
Definition: spgxlog.c:860
static void spgRedoMoveLeafs(XLogReaderState *record)
Definition: spgxlog.c:171
static void spgRedoAddNode(XLogReaderState *record)
Definition: spgxlog.c:284
static MemoryContext opCtx
Definition: spgxlog.c:25
static void spgRedoVacuumLeaf(XLogReaderState *record)
Definition: spgxlog.c:751
static void spgRedoPickSplit(XLogReaderState *record)
Definition: spgxlog.c:529
static void spgRedoAddLeaf(XLogReaderState *record)
Definition: spgxlog.c:74

References elog, MemoryContextReset(), MemoryContextSwitchTo(), opCtx, PANIC, spgRedoAddLeaf(), spgRedoAddNode(), spgRedoMoveLeafs(), spgRedoPickSplit(), spgRedoSplitTuple(), spgRedoVacuumLeaf(), spgRedoVacuumRedirect(), spgRedoVacuumRoot(), XLOG_SPGIST_ADD_LEAF, XLOG_SPGIST_ADD_NODE, XLOG_SPGIST_MOVE_LEAFS, XLOG_SPGIST_PICKSPLIT, XLOG_SPGIST_SPLIT_TUPLE, XLOG_SPGIST_VACUUM_LEAF, XLOG_SPGIST_VACUUM_REDIRECT, XLOG_SPGIST_VACUUM_ROOT, XLogRecGetInfo, and XLR_INFO_MASK.

◆ spg_xlog_cleanup()

void spg_xlog_cleanup ( void  )

Definition at line 984 of file spgxlog.c.

985 {
987  opCtx = NULL;
988 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:454

References MemoryContextDelete(), and opCtx.

◆ spg_xlog_startup()

void spg_xlog_startup ( void  )

Definition at line 976 of file spgxlog.c.

977 {
979  "SP-GiST temporary context",
981 }
MemoryContext CurrentMemoryContext
Definition: mcxt.c:143
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:160

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, CurrentMemoryContext, and opCtx.