PostgreSQL Source Code git master
Data Structures | Macros | Typedefs | Functions
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   ginxlogInsert
 
struct   ginxlogInsertEntry
 
 
 
 
struct   ginxlogSplit
 
 
struct   ginxlogDeletePage
 
struct   ginxlogUpdateMeta
 
 
 

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 ginxlogSplit  ginxlogSplit
 
 
 
 
 
 

Functions

void  gin_redo (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 202 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 194 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,
XLogReaderStaterecord 
)

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 if (XLogRecBlockImageApply(record, 0))
105 appendStringInfoString(buf, " (full page image)");
106 else
107 appendStringInfoString(buf, " (full page image, for WAL verification)");
108 }
109 else
110 {
111 char *payload = XLogRecGetBlockData(record, 0, NULL);
112
113 if (!(xlrec->flags & GIN_INSERT_ISDATA))
114 appendStringInfo(buf, " isdelete: %c",
115 (((ginxlogInsertEntry *) payload)->isDelete) ? 'T' : 'F');
116 else if (xlrec->flags & GIN_INSERT_ISLEAF)
118 else
119 {
120 ginxlogInsertDataInternal *insertData =
121 (ginxlogInsertDataInternal *) payload;
122
123 appendStringInfo(buf, " pitem: %u-%u/%u",
127 }
128 }
129 }
130 break;
131 case XLOG_GIN_SPLIT:
132 {
133 ginxlogSplit *xlrec = (ginxlogSplit *) rec;
134
135 appendStringInfo(buf, "isrootsplit: %c",
136 (((ginxlogSplit *) rec)->flags & GIN_SPLIT_ROOT) ? 'T' : 'F');
137 appendStringInfo(buf, " isdata: %c isleaf: %c",
138 (xlrec->flags & GIN_INSERT_ISDATA) ? 'T' : 'F',
139 (xlrec->flags & GIN_INSERT_ISLEAF) ? 'T' : 'F');
140 }
141 break;
143 /* no further information */
144 break;
146 {
147 if (XLogRecHasBlockImage(record, 0))
148 {
149 if (XLogRecBlockImageApply(record, 0))
150 appendStringInfoString(buf, " (full page image)");
151 else
152 appendStringInfoString(buf, " (full page image, for WAL verification)");
153 }
154 else
155 {
158
159 desc_recompress_leaf(buf, &xlrec->data);
160 }
161 }
162 break;
164 /* no further information */
165 break;
167 /* no further information */
168 break;
170 /* no further information */
171 break;
173 appendStringInfo(buf, "ndeleted: %d",
174 ((ginxlogDeleteListPages *) rec)->ndeleted);
175 break;
176 }
177}
uint32 BlockNumber
Definition: block.h:31
struct BlockIdData BlockIdData
static BlockNumber BlockIdGetBlockNumber(const BlockIdData *blockId)
Definition: block.h:103
uint8_t uint8
Definition: c.h:536
#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:194
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
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:230
Definition: block.h:54
ItemPointerData key
Definition: ginblock.h:186
PostingItem newitem
Definition: ginxlog.h:100
uint16 flags
Definition: ginxlog.h:39
uint16 flags
Definition: ginxlog.h:118
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:410
#define XLogRecBlockImageApply(decoder, block_id)
Definition: xlogreader.h:425
#define XLogRecGetData(decoder)
Definition: xlogreader.h:415
#define XLogRecHasBlockImage(decoder, block_id)
Definition: xlogreader.h:423

References appendStringInfo(), appendStringInfoString(), BlockIdGetBlockNumber(), buf, 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_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, and XLogRecHasBlockImage.

gin_identify()

const char * gin_identify ( uint8  info )

Definition at line 180 of file gindesc.c.

181{
182 const char *id = NULL;
183
184 switch (info & ~XLR_INFO_MASK)
185 {
187 id = "CREATE_PTREE";
188 break;
189 case XLOG_GIN_INSERT:
190 id = "INSERT";
191 break;
192 case XLOG_GIN_SPLIT:
193 id = "SPLIT";
194 break;
196 id = "VACUUM_PAGE";
197 break;
199 id = "VACUUM_DATA_LEAF_PAGE";
200 break;
202 id = "DELETE_PAGE";
203 break;
205 id = "UPDATE_META_PAGE";
206 break;
208 id = "INSERT_LISTPAGE";
209 break;
211 id = "DELETE_LISTPAGE";
212 break;
213 }
214
215 return id;
216}
#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 792 of file ginxlog.c.

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

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 ( XLogReaderStaterecord )

Definition at line 725 of file ginxlog.c.

726{
727 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
728 MemoryContext oldCtx;
729
730 /*
731 * GIN indexes do not require any conflict processing. NB: If we ever
732 * implement a similar optimization as we have in b-tree, and remove
733 * killed tuples outside VACUUM, we'll need to handle that here.
734 */
735
737 switch (info)
738 {
740 ginRedoCreatePTree(record);
741 break;
742 case XLOG_GIN_INSERT:
743 ginRedoInsert(record);
744 break;
745 case XLOG_GIN_SPLIT:
746 ginRedoSplit(record);
747 break;
749 ginRedoVacuumPage(record);
750 break;
753 break;
755 ginRedoDeletePage(record);
756 break;
758 ginRedoUpdateMetapage(record);
759 break;
761 ginRedoInsertListPage(record);
762 break;
765 break;
766 default:
767 elog(PANIC, "gin_redo: unknown op code %u", info);
768 }
769 MemoryContextSwitchTo(oldCtx);
771}
#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:674
static void ginRedoUpdateMetapage(XLogReaderState *record)
Definition: ginxlog.c:527
static void ginRedoInsertListPage(XLogReaderState *record)
Definition: ginxlog.c:619
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 782 of file ginxlog.c.

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

References MemoryContextDelete(), and opCtx.

gin_xlog_startup()

void gin_xlog_startup ( void  )

Definition at line 774 of file ginxlog.c.

775{
777 "GIN recovery temporary context",
779}
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.

AltStyle によって変換されたページ (->オリジナル) /