PostgreSQL Source Code  git master
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.

Referenced by moveLeafs(), and spgRedoMoveLeafs().

◆ SizeOfSpgxlogPickSplit

#define SizeOfSpgxlogPickSplit   offsetof(spgxlogPickSplit, offsets)

Definition at line 199 of file spgxlog.h.

Referenced by doPickSplit(), and spgRedoPickSplit().

◆ SizeOfSpgxlogVacuumLeaf

#define SizeOfSpgxlogVacuumLeaf   offsetof(spgxlogVacuumLeaf, offsets)

Definition at line 223 of file spgxlog.h.

Referenced by spgRedoVacuumLeaf(), and vacuumLeafPage().

◆ SizeOfSpgxlogVacuumRedirect

#define SizeOfSpgxlogVacuumRedirect   offsetof(spgxlogVacuumRedirect, offsets)

Definition at line 248 of file spgxlog.h.

Referenced by vacuumRedirectAndPlaceholder().

◆ SizeOfSpgxlogVacuumRoot

#define SizeOfSpgxlogVacuumRoot   offsetof(spgxlogVacuumRoot, offsets)

Definition at line 236 of file spgxlog.h.

Referenced by vacuumLeafRoot().

◆ XLOG_SPGIST_ADD_LEAF

#define XLOG_SPGIST_ADD_LEAF   0x10

Definition at line 22 of file spgxlog.h.

Referenced by addLeafTuple(), spg_desc(), spg_identify(), and spg_redo().

◆ XLOG_SPGIST_ADD_NODE

#define XLOG_SPGIST_ADD_NODE   0x30

Definition at line 24 of file spgxlog.h.

Referenced by spg_desc(), spg_identify(), spg_redo(), and spgAddNodeAction().

◆ XLOG_SPGIST_MOVE_LEAFS

#define XLOG_SPGIST_MOVE_LEAFS   0x20

Definition at line 23 of file spgxlog.h.

Referenced by moveLeafs(), spg_desc(), spg_identify(), and spg_redo().

◆ XLOG_SPGIST_PICKSPLIT

#define XLOG_SPGIST_PICKSPLIT   0x50

Definition at line 26 of file spgxlog.h.

Referenced by doPickSplit(), spg_desc(), spg_identify(), and spg_redo().

◆ XLOG_SPGIST_SPLIT_TUPLE

#define XLOG_SPGIST_SPLIT_TUPLE   0x40

Definition at line 25 of file spgxlog.h.

Referenced by spg_desc(), spg_identify(), spg_redo(), and spgSplitNodeAction().

◆ XLOG_SPGIST_VACUUM_LEAF

#define XLOG_SPGIST_VACUUM_LEAF   0x60

Definition at line 27 of file spgxlog.h.

Referenced by spg_desc(), spg_identify(), spg_redo(), and vacuumLeafPage().

◆ XLOG_SPGIST_VACUUM_REDIRECT

#define XLOG_SPGIST_VACUUM_REDIRECT   0x80

Definition at line 29 of file spgxlog.h.

Referenced by spg_desc(), spg_identify(), spg_redo(), and vacuumRedirectAndPlaceholder().

◆ XLOG_SPGIST_VACUUM_ROOT

#define XLOG_SPGIST_VACUUM_ROOT   0x70

Definition at line 28 of file spgxlog.h.

Referenced by spg_desc(), spg_identify(), spg_redo(), and vacuumLeafRoot().

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.

References appendStringInfo(), appendStringInfoString(), spgxlogPickSplit::innerIsParent, spgxlogPickSplit::isRootSplit, spgxlogPickSplit::nDelete, spgxlogAddLeaf::newPage, spgxlogPickSplit::nInsert, spgxlogAddLeaf::offnumHeadLeaf, spgxlogAddLeaf::offnumLeaf, spgxlogAddLeaf::offnumParent, spgxlogAddLeaf::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.

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 }
#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
#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
bool isRootSplit
Definition: spgxlog.h:167

◆ spg_identify()

const char* spg_identify ( uint8  info)

Definition at line 83 of file spgdesc.c.

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.

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 }
#define XLOG_SPGIST_MOVE_LEAFS
Definition: spgxlog.h:23
#define XLOG_SPGIST_VACUUM_REDIRECT
Definition: spgxlog.h:29
#define XLOG_SPGIST_SPLIT_TUPLE
Definition: spgxlog.h:25
#define XLOG_SPGIST_ADD_NODE
Definition: spgxlog.h:24
#define XLOG_SPGIST_ADD_LEAF
Definition: spgxlog.h:22
#define XLOG_SPGIST_PICKSPLIT
Definition: spgxlog.h:26
#define XLOG_SPGIST_VACUUM_ROOT
Definition: spgxlog.h:28
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_SPGIST_VACUUM_LEAF
Definition: spgxlog.h:27

◆ spg_mask()

void spg_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 998 of file spgxlog.c.

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

999 {
1000  Page page = (Page) pagedata;
1001  PageHeader pagehdr = (PageHeader) page;
1002 
1004 
1005  mask_page_hint_bits(page);
1006 
1007  /*
1008  * Mask the unused space, but only if the page's pd_lower appears to have
1009  * been set correctly.
1010  */
1011  if (pagehdr->pd_lower > SizeOfPageHeaderData)
1012  mask_unused_space(page);
1013 }
void mask_page_hint_bits(Page page)
Definition: bufmask.c:46
#define SizeOfPageHeaderData
Definition: bufpage.h:216
void mask_unused_space(Page page)
Definition: bufmask.c:71
void mask_page_lsn_and_checksum(Page page)
Definition: bufmask.c:31
PageHeaderData * PageHeader
Definition: bufpage.h:166
Pointer Page
Definition: bufpage.h:78
LocationIndex pd_lower
Definition: bufpage.h:158

◆ spg_redo()

void spg_redo ( XLogReaderState record)

Definition at line 939 of file spgxlog.c.

References elog, MemoryContextReset(), MemoryContextSwitchTo(), 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.

940 {
941  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
942  MemoryContext oldCxt;
943 
944  oldCxt = MemoryContextSwitchTo(opCtx);
945  switch (info)
946  {
948  spgRedoAddLeaf(record);
949  break;
951  spgRedoMoveLeafs(record);
952  break;
954  spgRedoAddNode(record);
955  break;
957  spgRedoSplitTuple(record);
958  break;
960  spgRedoPickSplit(record);
961  break;
963  spgRedoVacuumLeaf(record);
964  break;
966  spgRedoVacuumRoot(record);
967  break;
969  spgRedoVacuumRedirect(record);
970  break;
971  default:
972  elog(PANIC, "spg_redo: unknown op code %u", info);
973  }
974 
975  MemoryContextSwitchTo(oldCxt);
977 }
#define XLOG_SPGIST_MOVE_LEAFS
Definition: spgxlog.h:23
static void spgRedoVacuumRedirect(XLogReaderState *record)
Definition: spgxlog.c:862
#define XLOG_SPGIST_VACUUM_REDIRECT
Definition: spgxlog.h:29
static MemoryContext opCtx
Definition: spgxlog.c:27
#define XLOG_SPGIST_SPLIT_TUPLE
Definition: spgxlog.h:25
static void spgRedoAddNode(XLogReaderState *record)
Definition: spgxlog.c:286
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
unsigned char uint8
Definition: c.h:356
static void spgRedoSplitTuple(XLogReaderState *record)
Definition: spgxlog.c:453
#define XLOG_SPGIST_ADD_NODE
Definition: spgxlog.h:24
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:136
#define XLOG_SPGIST_ADD_LEAF
Definition: spgxlog.h:22
#define PANIC
Definition: elog.h:53
#define XLOG_SPGIST_PICKSPLIT
Definition: spgxlog.h:26
#define XLOG_SPGIST_VACUUM_ROOT
Definition: spgxlog.h:28
static void spgRedoAddLeaf(XLogReaderState *record)
Definition: spgxlog.c:76
static void spgRedoVacuumLeaf(XLogReaderState *record)
Definition: spgxlog.c:753
static void spgRedoPickSplit(XLogReaderState *record)
Definition: spgxlog.c:531
static void spgRedoVacuumRoot(XLogReaderState *record)
Definition: spgxlog.c:836
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:242
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_SPGIST_VACUUM_LEAF
Definition: spgxlog.h:27
#define elog(elevel,...)
Definition: elog.h:226
static void spgRedoMoveLeafs(XLogReaderState *record)
Definition: spgxlog.c:173

◆ spg_xlog_cleanup()

void spg_xlog_cleanup ( void  )

Definition at line 988 of file spgxlog.c.

References MemoryContextDelete().

989 {
991  opCtx = NULL;
992 }
static MemoryContext opCtx
Definition: spgxlog.c:27
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:211

◆ spg_xlog_startup()

void spg_xlog_startup ( void  )

Definition at line 980 of file spgxlog.c.

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, and CurrentMemoryContext.

981 {
983  "SP-GiST temporary context",
985 }
static MemoryContext opCtx
Definition: spgxlog.c:27
#define AllocSetContextCreate
Definition: memutils.h:170
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:192
MemoryContext CurrentMemoryContext
Definition: mcxt.c:38