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

Go to the source code of this file.

Data Structures

struct  ginxlogCreatePostingTree
 
struct  ginxlogInsert
 
struct  ginxlogInsertEntry
 
struct  ginxlogRecompressDataLeaf
 
struct  ginxlogSegmentAction
 
struct  ginxlogInsertDataInternal
 
struct  ginxlogSplit
 
struct  ginxlogVacuumDataLeafPage
 
struct  ginxlogDeletePage
 
struct  ginxlogUpdateMeta
 
struct  ginxlogInsertListPage
 
struct  ginxlogDeleteListPages
 

Macros

#define XLOG_GIN_CREATE_INDEX   0x00
 
#define XLOG_GIN_CREATE_PTREE   0x10
 
#define XLOG_GIN_INSERT   0x20
 
#define GIN_SEGMENT_UNMODIFIED   0 /* no action (not used in WAL records) */
 
#define GIN_SEGMENT_DELETE   1 /* a whole segment is removed */
 
#define GIN_SEGMENT_INSERT   2 /* a whole segment is added */
 
#define GIN_SEGMENT_REPLACE   3 /* a segment is replaced */
 
#define GIN_SEGMENT_ADDITEMS   4 /* items are added to existing segment */
 
#define XLOG_GIN_SPLIT   0x30
 
#define GIN_INSERT_ISDATA   0x01 /* for both insert and split records */
 
#define GIN_INSERT_ISLEAF   0x02 /* ditto */
 
#define GIN_SPLIT_ROOT   0x04 /* only for split records */
 
#define XLOG_GIN_VACUUM_PAGE   0x40
 
#define XLOG_GIN_VACUUM_DATA_LEAF_PAGE   0x90
 
#define XLOG_GIN_DELETE_PAGE   0x50
 
#define XLOG_GIN_UPDATE_META_PAGE   0x60
 
#define XLOG_GIN_INSERT_LISTPAGE   0x70
 
#define XLOG_GIN_DELETE_LISTPAGE   0x80
 
#define GIN_NDELETE_AT_ONCE   Min(16, XLR_MAX_BLOCK_ID - 1)
 

Typedefs

typedef struct
ginxlogCreatePostingTree 
ginxlogCreatePostingTree
 
typedef struct ginxlogSplit ginxlogSplit
 
typedef struct
ginxlogVacuumDataLeafPage 
ginxlogVacuumDataLeafPage
 
typedef struct ginxlogDeletePage ginxlogDeletePage
 
typedef struct ginxlogUpdateMeta ginxlogUpdateMeta
 
typedef struct
ginxlogInsertListPage 
ginxlogInsertListPage
 
typedef struct
ginxlogDeleteListPages 
ginxlogDeleteListPages
 

Functions

void gin_redo (XLogReaderState *record)
 
void gin_desc (StringInfo buf, XLogReaderState *record)
 
const char * gin_identify (uint8 info)
 
void gin_xlog_startup (void)
 
void gin_xlog_cleanup (void)
 
void gin_mask (char *pagedata, BlockNumber blkno)
 

Macro Definition Documentation

#define GIN_INSERT_ISDATA   0x01 /* for both insert and split records */

Definition at line 126 of file ginxlog.h.

Referenced by gin_desc(), ginPlaceToPage(), and ginRedoInsert().

#define GIN_INSERT_ISLEAF   0x02 /* ditto */

Definition at line 127 of file ginxlog.h.

Referenced by gin_desc(), ginPlaceToPage(), ginRedoInsert(), and ginRedoSplit().

#define GIN_NDELETE_AT_ONCE   Min(16, XLR_MAX_BLOCK_ID - 1)

Definition at line 203 of file ginxlog.h.

Referenced by shiftList().

#define GIN_SEGMENT_ADDITEMS   4 /* items are added to existing segment */
#define GIN_SEGMENT_INSERT   2 /* a whole segment is added */
#define GIN_SEGMENT_REPLACE   3 /* a segment is replaced */
#define GIN_SEGMENT_UNMODIFIED   0 /* no action (not used in WAL records) */
#define GIN_SPLIT_ROOT   0x04 /* only for split records */

Definition at line 128 of file ginxlog.h.

Referenced by gin_desc(), ginPlaceToPage(), and ginRedoSplit().

#define XLOG_GIN_CREATE_INDEX   0x00

Definition at line 19 of file ginxlog.h.

Referenced by gin_desc(), gin_identify(), gin_redo(), and ginbuild().

#define XLOG_GIN_CREATE_PTREE   0x10

Definition at line 21 of file ginxlog.h.

Referenced by createPostingTree(), gin_desc(), gin_identify(), and gin_redo().

#define XLOG_GIN_DELETE_LISTPAGE   0x80

Definition at line 195 of file ginxlog.h.

Referenced by gin_desc(), gin_identify(), gin_redo(), and shiftList().

#define XLOG_GIN_DELETE_PAGE   0x50

Definition at line 155 of file ginxlog.h.

Referenced by gin_desc(), gin_identify(), gin_redo(), and ginDeletePage().

#define XLOG_GIN_INSERT   0x20

Definition at line 37 of file ginxlog.h.

Referenced by gin_desc(), gin_identify(), gin_redo(), and ginPlaceToPage().

#define XLOG_GIN_INSERT_LISTPAGE   0x70

Definition at line 181 of file ginxlog.h.

Referenced by gin_desc(), gin_identify(), gin_redo(), and writeListPage().

#define XLOG_GIN_SPLIT   0x30

Definition at line 111 of file ginxlog.h.

Referenced by gin_desc(), gin_identify(), gin_redo(), and ginPlaceToPage().

#define XLOG_GIN_UPDATE_META_PAGE   0x60

Definition at line 163 of file ginxlog.h.

Referenced by gin_desc(), gin_identify(), gin_redo(), ginHeapTupleFastInsert(), and ginUpdateStats().

#define XLOG_GIN_VACUUM_DATA_LEAF_PAGE   0x90

Definition at line 143 of file ginxlog.h.

Referenced by gin_desc(), gin_identify(), gin_redo(), and ginVacuumPostingTreeLeaf().

#define XLOG_GIN_VACUUM_PAGE   0x40

Definition at line 137 of file ginxlog.h.

Referenced by gin_desc(), gin_identify(), gin_redo(), and xlogVacuumPage().

Typedef Documentation

Function Documentation

void gin_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 74 of file gindesc.c.

References appendStringInfo(), appendStringInfoString(), BlockIdGetBlockNumber, ginxlogVacuumDataLeafPage::data, desc_recompress_leaf(), ginxlogInsert::flags, ginxlogSplit::flags, GIN_INSERT_ISDATA, GIN_INSERT_ISLEAF, GIN_SPLIT_ROOT, ItemPointerGetBlockNumber, ItemPointerGetOffsetNumber, PostingItem::key, ginxlogInsertDataInternal::newitem, PostingItemGetBlockNumber, XLOG_GIN_CREATE_INDEX, XLOG_GIN_CREATE_PTREE, XLOG_GIN_DELETE_LISTPAGE, XLOG_GIN_DELETE_PAGE, XLOG_GIN_INSERT, XLOG_GIN_INSERT_LISTPAGE, XLOG_GIN_SPLIT, XLOG_GIN_UPDATE_META_PAGE, XLOG_GIN_VACUUM_DATA_LEAF_PAGE, XLOG_GIN_VACUUM_PAGE, XLogRecBlockImageApply, XLogRecGetBlockData(), XLogRecGetData, XLogRecGetInfo, XLogRecHasBlockImage, and XLR_INFO_MASK.

75 {
76  char *rec = XLogRecGetData(record);
77  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
78 
79  switch (info)
80  {
82  /* no further information */
83  break;
85  /* no further information */
86  break;
87  case XLOG_GIN_INSERT:
88  {
89  ginxlogInsert *xlrec = (ginxlogInsert *) rec;
90 
91  appendStringInfo(buf, "isdata: %c isleaf: %c",
92  (xlrec->flags & GIN_INSERT_ISDATA) ? 'T' : 'F',
93  (xlrec->flags & GIN_INSERT_ISLEAF) ? 'T' : 'F');
94  if (!(xlrec->flags & GIN_INSERT_ISLEAF))
95  {
96  char *payload = rec + sizeof(ginxlogInsert);
97  BlockNumber leftChildBlkno;
98  BlockNumber rightChildBlkno;
99 
100  leftChildBlkno = BlockIdGetBlockNumber((BlockId) payload);
101  payload += sizeof(BlockIdData);
102  rightChildBlkno = BlockIdGetBlockNumber((BlockId) payload);
103  payload += sizeof(BlockNumber);
104  appendStringInfo(buf, " children: %u/%u",
105  leftChildBlkno, rightChildBlkno);
106  }
107  if (XLogRecHasBlockImage(record, 0))
108  {
109  if (XLogRecBlockImageApply(record, 0))
110  appendStringInfoString(buf, " (full page image)");
111  else
112  appendStringInfoString(buf, " (full page image, for WAL verification)");
113  }
114  else
115  {
116  char *payload = XLogRecGetBlockData(record, 0, NULL);
117 
118  if (!(xlrec->flags & GIN_INSERT_ISDATA))
119  appendStringInfo(buf, " isdelete: %c",
120  (((ginxlogInsertEntry *) payload)->isDelete) ? 'T' : 'F');
121  else if (xlrec->flags & GIN_INSERT_ISLEAF)
123  else
124  {
125  ginxlogInsertDataInternal *insertData =
126  (ginxlogInsertDataInternal *) payload;
127 
128  appendStringInfo(buf, " pitem: %u-%u/%u",
129  PostingItemGetBlockNumber(&insertData->newitem),
130  ItemPointerGetBlockNumber(&insertData->newitem.key),
131  ItemPointerGetOffsetNumber(&insertData->newitem.key));
132  }
133  }
134  }
135  break;
136  case XLOG_GIN_SPLIT:
137  {
138  ginxlogSplit *xlrec = (ginxlogSplit *) rec;
139 
140  appendStringInfo(buf, "isrootsplit: %c",
141  (((ginxlogSplit *) rec)->flags & GIN_SPLIT_ROOT) ? 'T' : 'F');
142  appendStringInfo(buf, " isdata: %c isleaf: %c",
143  (xlrec->flags & GIN_INSERT_ISDATA) ? 'T' : 'F',
144  (xlrec->flags & GIN_INSERT_ISLEAF) ? 'T' : 'F');
145  }
146  break;
148  /* no further information */
149  break;
151  {
152  if (XLogRecHasBlockImage(record, 0))
153  {
154  if (XLogRecBlockImageApply(record, 0))
155  appendStringInfoString(buf, " (full page image)");
156  else
157  appendStringInfoString(buf, " (full page image, for WAL verification)");
158  }
159  else
160  {
162  (ginxlogVacuumDataLeafPage *) XLogRecGetBlockData(record, 0, NULL);
163 
164  desc_recompress_leaf(buf, &xlrec->data);
165  }
166  }
167  break;
169  /* no further information */
170  break;
172  /* no further information */
173  break;
175  /* no further information */
176  break;
178  appendStringInfo(buf, "ndeleted: %d",
179  ((ginxlogDeleteListPages *) rec)->ndeleted);
180  break;
181  }
182 }
#define BlockIdGetBlockNumber(blockId)
Definition: block.h:115
#define XLogRecHasBlockImage(decoder, block_id)
Definition: xlogreader.h:231
unsigned char uint8
Definition: c.h:256
uint32 BlockNumber
Definition: block.h:31
#define GIN_SPLIT_ROOT
Definition: ginxlog.h:128
#define GIN_INSERT_ISLEAF
Definition: ginxlog.h:127
uint16 flags
Definition: ginxlog.h:41
ginxlogRecompressDataLeaf data
Definition: ginxlog.h:147
#define XLOG_GIN_INSERT_LISTPAGE
Definition: ginxlog.h:181
#define XLogRecGetData(decoder)
Definition: xlogreader.h:226
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:78
#define XLOG_GIN_CREATE_PTREE
Definition: ginxlog.h:21
#define XLOG_GIN_UPDATE_META_PAGE
Definition: ginxlog.h:163
static void desc_recompress_leaf(StringInfo buf, ginxlogRecompressDataLeaf *insertData)
Definition: gindesc.c:23
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:157
#define GIN_INSERT_ISDATA
Definition: ginxlog.h:126
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:222
#define XLOG_GIN_CREATE_INDEX
Definition: ginxlog.h:19
#define XLOG_GIN_VACUUM_DATA_LEAF_PAGE
Definition: ginxlog.h:143
#define XLOG_GIN_VACUUM_PAGE
Definition: ginxlog.h:137
char * XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len)
Definition: xlogreader.c:1333
ItemPointerData key
Definition: ginblock.h:180
struct BlockIdData BlockIdData
#define PostingItemGetBlockNumber(pointer)
Definition: ginblock.h:183
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define ItemPointerGetOffsetNumber(pointer)
Definition: itemptr.h:95
#define XLOG_GIN_INSERT
Definition: ginxlog.h:37
#define XLogRecBlockImageApply(decoder, block_id)
Definition: xlogreader.h:233
#define ItemPointerGetBlockNumber(pointer)
Definition: itemptr.h:76
#define XLOG_GIN_DELETE_PAGE
Definition: ginxlog.h:155
uint16 flags
Definition: ginxlog.h:120
#define XLOG_GIN_SPLIT
Definition: ginxlog.h:111
#define XLOG_GIN_DELETE_LISTPAGE
Definition: ginxlog.h:195
const char* gin_identify ( uint8  info)

Definition at line 185 of file gindesc.c.

References XLOG_GIN_CREATE_INDEX, XLOG_GIN_CREATE_PTREE, XLOG_GIN_DELETE_LISTPAGE, XLOG_GIN_DELETE_PAGE, XLOG_GIN_INSERT, XLOG_GIN_INSERT_LISTPAGE, XLOG_GIN_SPLIT, XLOG_GIN_UPDATE_META_PAGE, XLOG_GIN_VACUUM_DATA_LEAF_PAGE, XLOG_GIN_VACUUM_PAGE, and XLR_INFO_MASK.

186 {
187  const char *id = NULL;
188 
189  switch (info & ~XLR_INFO_MASK)
190  {
192  id = "CREATE_INDEX";
193  break;
195  id = "CREATE_PTREE";
196  break;
197  case XLOG_GIN_INSERT:
198  id = "INSERT";
199  break;
200  case XLOG_GIN_SPLIT:
201  id = "SPLIT";
202  break;
204  id = "VACUUM_PAGE";
205  break;
207  id = "VACUUM_DATA_LEAF_PAGE";
208  break;
210  id = "DELETE_PAGE";
211  break;
213  id = "UPDATE_META_PAGE";
214  break;
216  id = "INSERT_LISTPAGE";
217  break;
219  id = "DELETE_LISTPAGE";
220  break;
221  }
222 
223  return id;
224 }
#define XLOG_GIN_INSERT_LISTPAGE
Definition: ginxlog.h:181
#define XLOG_GIN_CREATE_PTREE
Definition: ginxlog.h:21
#define XLOG_GIN_UPDATE_META_PAGE
Definition: ginxlog.h:163
#define XLOG_GIN_CREATE_INDEX
Definition: ginxlog.h:19
#define XLOG_GIN_VACUUM_DATA_LEAF_PAGE
Definition: ginxlog.h:143
#define XLOG_GIN_VACUUM_PAGE
Definition: ginxlog.h:137
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_GIN_INSERT
Definition: ginxlog.h:37
#define XLOG_GIN_DELETE_PAGE
Definition: ginxlog.h:155
#define XLOG_GIN_SPLIT
Definition: ginxlog.h:111
#define XLOG_GIN_DELETE_LISTPAGE
Definition: ginxlog.h:195
void gin_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 768 of file ginxlog.c.

References GinPageOpaqueData::flags, GIN_DELETED, GIN_META, GinPageGetOpaque, mask_page_content(), mask_page_hint_bits(), mask_page_lsn_and_checksum(), and mask_unused_space().

769 {
770  Page page = (Page) pagedata;
771  GinPageOpaque opaque;
772 
774  opaque = GinPageGetOpaque(page);
775 
776  mask_page_hint_bits(page);
777 
778  /*
779  * GIN metapage doesn't use pd_lower/pd_upper. Other page types do. Hence,
780  * we need to apply masking for those pages.
781  */
782  if (opaque->flags != GIN_META)
783  {
784  /*
785  * For GIN_DELETED page, the page is initialized to empty. Hence, mask
786  * the page content.
787  */
788  if (opaque->flags & GIN_DELETED)
789  mask_page_content(page);
790  else
791  mask_unused_space(page);
792  }
793 }
#define GIN_DELETED
Definition: ginblock.h:41
void mask_page_hint_bits(Page page)
Definition: bufmask.c:46
#define GinPageGetOpaque(page)
Definition: ginblock.h:109
void mask_unused_space(Page page)
Definition: bufmask.c:71
void mask_page_content(Page page)
Definition: bufmask.c:119
#define GIN_META
Definition: ginblock.h:42
void mask_page_lsn_and_checksum(Page page)
Definition: bufmask.c:31
Pointer Page
Definition: bufpage.h:74
void gin_redo ( XLogReaderState record)

Definition at line 698 of file ginxlog.c.

References elog, ginRedoCreateIndex(), ginRedoCreatePTree(), ginRedoDeleteListPages(), ginRedoDeletePage(), ginRedoInsert(), ginRedoInsertListPage(), ginRedoSplit(), ginRedoUpdateMetapage(), ginRedoVacuumDataLeafPage(), ginRedoVacuumPage(), MemoryContextReset(), MemoryContextSwitchTo(), PANIC, XLOG_GIN_CREATE_INDEX, XLOG_GIN_CREATE_PTREE, XLOG_GIN_DELETE_LISTPAGE, XLOG_GIN_DELETE_PAGE, XLOG_GIN_INSERT, XLOG_GIN_INSERT_LISTPAGE, XLOG_GIN_SPLIT, XLOG_GIN_UPDATE_META_PAGE, XLOG_GIN_VACUUM_DATA_LEAF_PAGE, XLOG_GIN_VACUUM_PAGE, XLogRecGetInfo, and XLR_INFO_MASK.

699 {
700  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
701  MemoryContext oldCtx;
702 
703  /*
704  * GIN indexes do not require any conflict processing. NB: If we ever
705  * implement a similar optimization as we have in b-tree, and remove
706  * killed tuples outside VACUUM, we'll need to handle that here.
707  */
708 
709  oldCtx = MemoryContextSwitchTo(opCtx);
710  switch (info)
711  {
713  ginRedoCreateIndex(record);
714  break;
716  ginRedoCreatePTree(record);
717  break;
718  case XLOG_GIN_INSERT:
719  ginRedoInsert(record);
720  break;
721  case XLOG_GIN_SPLIT:
722  ginRedoSplit(record);
723  break;
725  ginRedoVacuumPage(record);
726  break;
729  break;
731  ginRedoDeletePage(record);
732  break;
734  ginRedoUpdateMetapage(record);
735  break;
737  ginRedoInsertListPage(record);
738  break;
740  ginRedoDeleteListPages(record);
741  break;
742  default:
743  elog(PANIC, "gin_redo: unknown op code %u", info);
744  }
745  MemoryContextSwitchTo(oldCtx);
747 }
static void ginRedoUpdateMetapage(XLogReaderState *record)
Definition: ginxlog.c:500
static void ginRedoSplit(XLogReaderState *record)
Definition: ginxlog.c:379
static MemoryContext opCtx
Definition: ginxlog.c:22
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
unsigned char uint8
Definition: c.h:256
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:135
#define PANIC
Definition: elog.h:53
#define XLOG_GIN_INSERT_LISTPAGE
Definition: ginxlog.h:181
static void ginRedoDeleteListPages(XLogReaderState *record)
Definition: ginxlog.c:647
#define XLOG_GIN_CREATE_PTREE
Definition: ginxlog.h:21
static void ginRedoVacuumDataLeafPage(XLogReaderState *record)
Definition: ginxlog.c:429
#define XLOG_GIN_UPDATE_META_PAGE
Definition: ginxlog.h:163
static void ginRedoCreatePTree(XLogReaderState *record)
Definition: ginxlog.c:74
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:222
#define XLOG_GIN_CREATE_INDEX
Definition: ginxlog.h:19
#define XLOG_GIN_VACUUM_DATA_LEAF_PAGE
Definition: ginxlog.h:143
#define XLOG_GIN_VACUUM_PAGE
Definition: ginxlog.h:137
static void ginRedoInsert(XLogReaderState *record)
Definition: ginxlog.c:324
static void ginRedoVacuumPage(XLogReaderState *record)
Definition: ginxlog.c:417
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_GIN_INSERT
Definition: ginxlog.h:37
static void ginRedoDeletePage(XLogReaderState *record)
Definition: ginxlog.c:454
#define elog
Definition: elog.h:219
static void ginRedoInsertListPage(XLogReaderState *record)
Definition: ginxlog.c:592
#define XLOG_GIN_DELETE_PAGE
Definition: ginxlog.h:155
static void ginRedoCreateIndex(XLogReaderState *record)
Definition: ginxlog.c:44
#define XLOG_GIN_SPLIT
Definition: ginxlog.h:111
#define XLOG_GIN_DELETE_LISTPAGE
Definition: ginxlog.h:195
void gin_xlog_cleanup ( void  )

Definition at line 758 of file ginxlog.c.

References MemoryContextDelete().

759 {
761  opCtx = NULL;
762 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:200
static MemoryContext opCtx
Definition: ginxlog.c:22
void gin_xlog_startup ( void  )

Definition at line 750 of file ginxlog.c.

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate(), and CurrentMemoryContext.

751 {
753  "GIN recovery temporary context",
755 }
static MemoryContext opCtx
Definition: ginxlog.c:22
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:165
MemoryContext CurrentMemoryContext
Definition: mcxt.c:37
MemoryContext AllocSetContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
Definition: aset.c:322