1/*--------------------------------------------------------------------------
3 * header file for postgres inverted index xlog implementation.
5 * Copyright (c) 2006-2025, PostgreSQL Global Development Group
7 * src/include/access/ginxlog.h
8 *--------------------------------------------------------------------------
19 #define XLOG_GIN_CREATE_PTREE 0x10
24 /* A compressed posting list follows */
28 * The format of the insertion record varies depending on the page type.
29 * ginxlogInsert is the common part between all variants.
31 * Backup Blk 0: target page
32 * Backup Blk 1: left child, if this insertion finishes an incomplete split
35 #define XLOG_GIN_INSERT 0x20
39 uint16 flags;
/* GIN_INSERT_ISLEAF and/or GIN_INSERT_ISDATA */
44 * 1. if not leaf page, block numbers of the left and right child pages
45 * whose split this insertion finishes, as BlockIdData[2] (beware of
46 * adding fields in this struct that would make them not 16-bit aligned)
48 * 2. a ginxlogInsertEntry or ginxlogRecompressDataLeaf struct, depending
51 * NB: the below structs are only 16-bit aligned when appended to a
52 * ginxlogInsert struct! Beware of adding fields to them that require
69 /* Variable number of 'actions' follow */
73 * Note: this struct is currently not used in code, and only acts as
74 * documentation. The WAL record format is as specified here, but the code
75 * uses straight access through a Pointer and memcpy to read/write these.
80 char type;
/* action type (see below) */
83 * Action-specific data follows. For INSERT and REPLACE actions that is a
84 * GinPostingList struct. For ADDITEMS, a uint16 for the number of items
85 * added, followed by the items themselves as ItemPointers. DELETE actions
86 * have no further data.
91 #define GIN_SEGMENT_UNMODIFIED 0 /* no action (not used in WAL records) */
92 #define GIN_SEGMENT_DELETE 1 /* a whole segment is removed */
93 #define GIN_SEGMENT_INSERT 2 /* a whole segment is added */
94 #define GIN_SEGMENT_REPLACE 3 /* a segment is replaced */
95 #define GIN_SEGMENT_ADDITEMS 4 /* items are added to existing segment */
104 * Backup Blk 0: new left page (= original page, if not root split)
105 * Backup Blk 1: new right page
106 * Backup Blk 2: original page / new root page, if root split
107 * Backup Blk 3: left child, if this insertion completes an earlier split
109 #define XLOG_GIN_SPLIT 0x30
122 * Flags used in ginxlogInsert and ginxlogSplit records
124 #define GIN_INSERT_ISDATA 0x01 /* for both insert and split records */
125 #define GIN_INSERT_ISLEAF 0x02 /* ditto */
126 #define GIN_SPLIT_ROOT 0x04 /* only for split records */
129 * Vacuum simply WAL-logs the whole page, when anything is modified. This
130 * is functionally identical to XLOG_FPI records, but is kept separate for
131 * debugging purposes. (When inspecting the WAL stream, it's easier to see
132 * what's going on when GIN vacuum records are marked as such, not as heap
133 * records.) This is currently only used for entry tree leaf pages.
135 #define XLOG_GIN_VACUUM_PAGE 0x40
138 * Vacuuming posting tree leaf page is WAL-logged like recompression caused
141 #define XLOG_GIN_VACUUM_DATA_LEAF_PAGE 0x90
149 * Backup Blk 0: deleted page
150 * Backup Blk 1: parent
151 * Backup Blk 2: left sibling
153 #define XLOG_GIN_DELETE_PAGE 0x50
162 #define XLOG_GIN_UPDATE_META_PAGE 0x60
165 * Backup Blk 0: metapage
166 * Backup Blk 1: tail page
175 * updated with that many tuples; else new sub
176 * list was inserted */
177 /* array of inserted tuples follows */
180 #define XLOG_GIN_INSERT_LISTPAGE 0x70
186 /* array of inserted tuples follows */
190 * Backup Blk 0: metapage
191 * Backup Blk 1 to (ndeleted + 1): deleted pages
194 #define XLOG_GIN_DELETE_LISTPAGE 0x80
197 * The WAL record for deleting list pages must contain a block reference to
198 * all the deleted pages, so the number of pages that can be deleted in one
199 * record is limited by XLR_MAX_BLOCK_ID. (block_id 0 is used for the
202 #define GIN_NDELETE_AT_ONCE Min(16, XLR_MAX_BLOCK_ID - 1)
216#endif /* GINXLOG_H */
struct ginxlogDeleteListPages ginxlogDeleteListPages
void gin_desc(StringInfo buf, XLogReaderState *record)
struct ginxlogVacuumDataLeafPage ginxlogVacuumDataLeafPage
void gin_redo(XLogReaderState *record)
void gin_mask(char *pagedata, BlockNumber blkno)
struct ginxlogInsertListPage ginxlogInsertListPage
void gin_xlog_startup(void)
const char * gin_identify(uint8 info)
void gin_xlog_cleanup(void)
struct ginxlogUpdateMeta ginxlogUpdateMeta
struct ginxlogCreatePostingTree ginxlogCreatePostingTree
struct ginxlogSplit ginxlogSplit
struct ginxlogDeletePage ginxlogDeletePage
OffsetNumber parentOffset
BlockNumber leftChildBlkno
BlockNumber rightChildBlkno
ginxlogRecompressDataLeaf data