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

◆ GIN_INSERT_ISDATA

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

Definition at line 124 of file ginxlog.h.

◆ GIN_INSERT_ISLEAF

#define GIN_INSERT_ISLEAF   0x02 /* ditto */

Definition at line 125 of file ginxlog.h.

◆ GIN_NDELETE_AT_ONCE

#define GIN_NDELETE_AT_ONCE   Min(16, XLR_MAX_BLOCK_ID - 1)

Definition at line 205 of file ginxlog.h.

◆ GIN_SEGMENT_ADDITEMS

#define GIN_SEGMENT_ADDITEMS   4 /* items are added to existing segment */

Definition at line 95 of file ginxlog.h.

◆ GIN_SEGMENT_DELETE

#define GIN_SEGMENT_DELETE   1 /* a whole segment is removed */

Definition at line 92 of file ginxlog.h.

◆ GIN_SEGMENT_INSERT

#define GIN_SEGMENT_INSERT   2 /* a whole segment is added */

Definition at line 93 of file ginxlog.h.

◆ GIN_SEGMENT_REPLACE

#define GIN_SEGMENT_REPLACE   3 /* a segment is replaced */

Definition at line 94 of file ginxlog.h.

◆ GIN_SEGMENT_UNMODIFIED

#define GIN_SEGMENT_UNMODIFIED   0 /* no action (not used in WAL records) */

Definition at line 91 of file ginxlog.h.

◆ GIN_SPLIT_ROOT

#define GIN_SPLIT_ROOT   0x04 /* only for split records */

Definition at line 126 of file ginxlog.h.

◆ XLOG_GIN_CREATE_PTREE

#define XLOG_GIN_CREATE_PTREE   0x10

Definition at line 19 of file ginxlog.h.

◆ XLOG_GIN_DELETE_LISTPAGE

#define XLOG_GIN_DELETE_LISTPAGE   0x80

Definition at line 197 of file ginxlog.h.

◆ XLOG_GIN_DELETE_PAGE

#define XLOG_GIN_DELETE_PAGE   0x50

Definition at line 153 of file ginxlog.h.

◆ XLOG_GIN_INSERT

#define XLOG_GIN_INSERT   0x20

Definition at line 35 of file ginxlog.h.

◆ XLOG_GIN_INSERT_LISTPAGE

#define XLOG_GIN_INSERT_LISTPAGE   0x70

Definition at line 180 of file ginxlog.h.

◆ XLOG_GIN_SPLIT

#define XLOG_GIN_SPLIT   0x30

Definition at line 109 of file ginxlog.h.

◆ XLOG_GIN_UPDATE_META_PAGE

#define XLOG_GIN_UPDATE_META_PAGE   0x60

Definition at line 162 of file ginxlog.h.

◆ XLOG_GIN_VACUUM_DATA_LEAF_PAGE

#define XLOG_GIN_VACUUM_DATA_LEAF_PAGE   0x90

Definition at line 141 of file ginxlog.h.

◆ XLOG_GIN_VACUUM_PAGE

#define XLOG_GIN_VACUUM_PAGE   0x40

Definition at line 135 of file ginxlog.h.

Typedef Documentation

◆ ginxlogCreatePostingTree

◆ ginxlogDeleteListPages

◆ ginxlogDeletePage

◆ ginxlogInsertListPage

◆ ginxlogSplit

typedef struct ginxlogSplit ginxlogSplit

◆ ginxlogUpdateMeta

◆ ginxlogVacuumDataLeafPage

Function Documentation

◆ gin_desc()

void gin_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 72 of file gindesc.c.

73{
74 char *rec = XLogRecGetData(record);
75 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
76
77 switch (info)
78 {
80 /* no further information */
81 break;
82 case XLOG_GIN_INSERT:
83 {
84 ginxlogInsert *xlrec = (ginxlogInsert *) rec;
85
86 appendStringInfo(buf, "isdata: %c isleaf: %c",
87 (xlrec->flags & GIN_INSERT_ISDATA) ? 'T' : 'F',
88 (xlrec->flags & GIN_INSERT_ISLEAF) ? 'T' : 'F');
89 if (!(xlrec->flags & GIN_INSERT_ISLEAF))
90 {
91 char *payload = rec + sizeof(ginxlogInsert);
92 BlockNumber leftChildBlkno;
93 BlockNumber rightChildBlkno;
94
95 leftChildBlkno = BlockIdGetBlockNumber((BlockId) payload);
96 payload += sizeof(BlockIdData);
97 rightChildBlkno = BlockIdGetBlockNumber((BlockId) payload);
98 payload += sizeof(BlockNumber);
99 appendStringInfo(buf, " children: %u/%u",
100 leftChildBlkno, rightChildBlkno);
101 }
102 if (!XLogRecHasBlockImage(record, 0))
103 {
104 char *payload = XLogRecGetBlockData(record, 0, NULL);
105
106 if (!(xlrec->flags & GIN_INSERT_ISDATA))
107 appendStringInfo(buf, " isdelete: %c",
108 (((ginxlogInsertEntry *) payload)->isDelete) ? 'T' : 'F');
109 else if (xlrec->flags & GIN_INSERT_ISLEAF)
111 else
112 {
113 ginxlogInsertDataInternal *insertData =
114 (ginxlogInsertDataInternal *) payload;
115
116 appendStringInfo(buf, " pitem: %u-%u/%u",
120 }
121 }
122 }
123 break;
124 case XLOG_GIN_SPLIT:
125 {
126 ginxlogSplit *xlrec = (ginxlogSplit *) rec;
127
128 appendStringInfo(buf, "isrootsplit: %c",
129 (((ginxlogSplit *) rec)->flags & GIN_SPLIT_ROOT) ? 'T' : 'F');
130 appendStringInfo(buf, " isdata: %c isleaf: %c",
131 (xlrec->flags & GIN_INSERT_ISDATA) ? 'T' : 'F',
132 (xlrec->flags & GIN_INSERT_ISLEAF) ? 'T' : 'F');
134 appendStringInfo(buf, " children: %u/%u",
135 xlrec->leftChildBlkno, xlrec->rightChildBlkno);
136 }
137 break;
139 /* no further information */
140 break;
142 {
143 if (!XLogRecHasBlockImage(record, 0))
144 {
147
148 desc_recompress_leaf(buf, &xlrec->data);
149 }
150 }
151 break;
153 /* no further information */
154 break;
156 {
157 ginxlogUpdateMeta *xlrec = (ginxlogUpdateMeta *) rec;
158
159 appendStringInfo(buf, "ntuples: %d", xlrec->ntuples);
160 if (xlrec->prevTail != InvalidBlockNumber)
161 appendStringInfo(buf, " prevTail: %u",
162 xlrec->prevTail);
163 if (xlrec->newRightlink != InvalidBlockNumber)
164 appendStringInfo(buf, " newRightLink: %u",
165 xlrec->newRightlink);
166 }
167 break;
169 {
171
172 appendStringInfo(buf, "ntuples: %d", xlrec->ntuples);
173 if (xlrec->rightlink != InvalidBlockNumber)
174 appendStringInfo(buf, " rightlink: %u",
175 xlrec->rightlink);
176 }
177 break;
179 appendStringInfo(buf, "ndeleted: %d",
180 ((ginxlogDeleteListPages *) rec)->ndeleted);
181 break;
182 }
183}
uint32 BlockNumber
Definition: block.h:31
struct BlockIdData BlockIdData
#define InvalidBlockNumber
Definition: block.h:33
static BlockNumber BlockIdGetBlockNumber(const BlockIdData *blockId)
Definition: block.h:103
uint8_t uint8
Definition: c.h:541
#define PostingItemGetBlockNumber(pointer)
Definition: ginblock.h:189
static void desc_recompress_leaf(StringInfo buf, ginxlogRecompressDataLeaf *insertData)
Definition: gindesc.c:21
#define GIN_INSERT_ISDATA
Definition: ginxlog.h:124
#define GIN_INSERT_ISLEAF
Definition: ginxlog.h:125
#define XLOG_GIN_UPDATE_META_PAGE
Definition: ginxlog.h:162
#define GIN_SPLIT_ROOT
Definition: ginxlog.h:126
#define XLOG_GIN_INSERT
Definition: ginxlog.h:35
#define XLOG_GIN_CREATE_PTREE
Definition: ginxlog.h:19
#define XLOG_GIN_VACUUM_PAGE
Definition: ginxlog.h:135
#define XLOG_GIN_DELETE_PAGE
Definition: ginxlog.h:153
#define XLOG_GIN_INSERT_LISTPAGE
Definition: ginxlog.h:180
#define XLOG_GIN_VACUUM_DATA_LEAF_PAGE
Definition: ginxlog.h:141
#define XLOG_GIN_SPLIT
Definition: ginxlog.h:109
#define XLOG_GIN_DELETE_LISTPAGE
Definition: ginxlog.h:197
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
Definition: itemptr.h:124
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
Definition: itemptr.h:103
static char * buf
Definition: pg_test_fsync.c:72
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:145
ItemPointerData key
Definition: ginblock.h:186
BlockNumber rightlink
Definition: ginxlog.h:187
uint16 flags
Definition: ginxlog.h:39
uint16 flags
Definition: ginxlog.h:118
BlockNumber leftChildBlkno
Definition: ginxlog.h:116
BlockNumber rightChildBlkno
Definition: ginxlog.h:117
BlockNumber prevTail
Definition: ginxlog.h:172
BlockNumber newRightlink
Definition: ginxlog.h:173
ginxlogRecompressDataLeaf data
Definition: ginxlog.h:145
char * XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len)
Definition: xlogreader.c:2045
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:409
#define XLogRecGetData(decoder)
Definition: xlogreader.h:414
#define XLogRecHasBlockImage(decoder, block_id)
Definition: xlogreader.h:422

References appendStringInfo(), BlockIdGetBlockNumber(), buf, ginxlogVacuumDataLeafPage::data, desc_recompress_leaf(), ginxlogInsert::flags, ginxlogSplit::flags, GIN_INSERT_ISDATA, GIN_INSERT_ISLEAF, GIN_SPLIT_ROOT, InvalidBlockNumber, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), PostingItem::key, ginxlogSplit::leftChildBlkno, ginxlogInsertDataInternal::newitem, ginxlogUpdateMeta::newRightlink, ginxlogUpdateMeta::ntuples, ginxlogInsertListPage::ntuples, PostingItemGetBlockNumber, ginxlogUpdateMeta::prevTail, ginxlogSplit::rightChildBlkno, ginxlogInsertListPage::rightlink, 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, XLogRecGetBlockData(), XLogRecGetData, XLogRecGetInfo, and XLogRecHasBlockImage.

◆ gin_identify()

const char * gin_identify ( uint8  info)

Definition at line 186 of file gindesc.c.

187{
188 const char *id = NULL;
189
190 switch (info & ~XLR_INFO_MASK)
191 {
193 id = "CREATE_PTREE";
194 break;
195 case XLOG_GIN_INSERT:
196 id = "INSERT";
197 break;
198 case XLOG_GIN_SPLIT:
199 id = "SPLIT";
200 break;
202 id = "VACUUM_PAGE";
203 break;
205 id = "VACUUM_DATA_LEAF_PAGE";
206 break;
208 id = "DELETE_PAGE";
209 break;
211 id = "UPDATE_META_PAGE";
212 break;
214 id = "INSERT_LISTPAGE";
215 break;
217 id = "DELETE_LISTPAGE";
218 break;
219 }
220
221 return id;
222}
#define XLR_INFO_MASK
Definition: xlogrecord.h:62

References 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.

◆ gin_mask()

void gin_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 791 of file ginxlog.c.

792{
793 Page page = (Page) pagedata;
794 PageHeader pagehdr = (PageHeader) page;
795 GinPageOpaque opaque;
796
798 opaque = GinPageGetOpaque(page);
799
801
802 /*
803 * For a GIN_DELETED page, the page is initialized to empty. Hence, mask
804 * the whole page content. For other pages, mask the hole if pd_lower
805 * appears to have been set correctly.
806 */
807 if (opaque->flags & GIN_DELETED)
808 mask_page_content(page);
809 else if (pagehdr->pd_lower > SizeOfPageHeaderData)
810 mask_unused_space(page);
811}
void mask_page_content(Page page)
Definition: bufmask.c:119
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
#define SizeOfPageHeaderData
Definition: bufpage.h:216
PageData * Page
Definition: bufpage.h:81
#define GinPageGetOpaque(page)
Definition: ginblock.h:110
#define GIN_DELETED
Definition: ginblock.h:43
LocationIndex pd_lower
Definition: bufpage.h:165

References GinPageOpaqueData::flags, GIN_DELETED, GinPageGetOpaque, mask_page_content(), mask_page_hint_bits(), mask_page_lsn_and_checksum(), mask_unused_space(), PageHeaderData::pd_lower, and SizeOfPageHeaderData.

◆ gin_redo()

void gin_redo ( XLogReaderState record)

Definition at line 724 of file ginxlog.c.

725{
726 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
727 MemoryContext oldCtx;
728
729 /*
730 * GIN indexes do not require any conflict processing. NB: If we ever
731 * implement a similar optimization as we have in b-tree, and remove
732 * killed tuples outside VACUUM, we'll need to handle that here.
733 */
734
736 switch (info)
737 {
739 ginRedoCreatePTree(record);
740 break;
741 case XLOG_GIN_INSERT:
742 ginRedoInsert(record);
743 break;
744 case XLOG_GIN_SPLIT:
745 ginRedoSplit(record);
746 break;
748 ginRedoVacuumPage(record);
749 break;
752 break;
754 ginRedoDeletePage(record);
755 break;
757 ginRedoUpdateMetapage(record);
758 break;
760 ginRedoInsertListPage(record);
761 break;
764 break;
765 default:
766 elog(PANIC, "gin_redo: unknown op code %u", info);
767 }
768 MemoryContextSwitchTo(oldCtx);
770}
#define PANIC
Definition: elog.h:42
#define elog(elevel,...)
Definition: elog.h:226
static void ginRedoInsert(XLogReaderState *record)
Definition: ginxlog.c:347
static void ginRedoSplit(XLogReaderState *record)
Definition: ginxlog.c:401
static void ginRedoDeletePage(XLogReaderState *record)
Definition: ginxlog.c:476
static void ginRedoVacuumDataLeafPage(XLogReaderState *record)
Definition: ginxlog.c:451
static void ginRedoDeleteListPages(XLogReaderState *record)
Definition: ginxlog.c:673
static void ginRedoUpdateMetapage(XLogReaderState *record)
Definition: ginxlog.c:527
static void ginRedoInsertListPage(XLogReaderState *record)
Definition: ginxlog.c:618
static MemoryContext opCtx
Definition: ginxlog.c:22
static void ginRedoCreatePTree(XLogReaderState *record)
Definition: ginxlog.c:44
static void ginRedoVacuumPage(XLogReaderState *record)
Definition: ginxlog.c:439
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:400
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:124

References elog, ginRedoCreatePTree(), ginRedoDeleteListPages(), ginRedoDeletePage(), ginRedoInsert(), ginRedoInsertListPage(), ginRedoSplit(), ginRedoUpdateMetapage(), ginRedoVacuumDataLeafPage(), ginRedoVacuumPage(), MemoryContextReset(), MemoryContextSwitchTo(), opCtx, PANIC, 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 XLogRecGetInfo.

◆ gin_xlog_cleanup()

void gin_xlog_cleanup ( void  )

Definition at line 781 of file ginxlog.c.

782{
784 opCtx = NULL;
785}
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:469

References MemoryContextDelete(), and opCtx.

◆ gin_xlog_startup()

void gin_xlog_startup ( void  )

Definition at line 773 of file ginxlog.c.

774{
776 "GIN recovery temporary context",
778}
MemoryContext CurrentMemoryContext
Definition: mcxt.c:160
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:160

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, CurrentMemoryContext, and opCtx.