1/*-------------------------------------------------------------------------
4 * header file for Postgres hash AM implementation
7 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/access/hash_xlog.h
12 *-------------------------------------------------------------------------
21/* Number of buffers required for XLOG_HASH_SQUEEZE_PAGE operation */
22 #define HASH_XLOG_FREE_OVFL_BUFS 6
25 * XLOG records for hash operations
27 #define XLOG_HASH_INIT_META_PAGE 0x00 /* initialize the meta page */
28 #define XLOG_HASH_INIT_BITMAP_PAGE 0x10 /* initialize the bitmap page */
29 #define XLOG_HASH_INSERT 0x20 /* add index tuple without split */
30 #define XLOG_HASH_ADD_OVFL_PAGE 0x30 /* add overflow page */
31 #define XLOG_HASH_SPLIT_ALLOCATE_PAGE 0x40 /* allocate new page for split */
32 #define XLOG_HASH_SPLIT_PAGE 0x50 /* split page */
33 #define XLOG_HASH_SPLIT_COMPLETE 0x60 /* completion of split operation */
34 #define XLOG_HASH_MOVE_PAGE_CONTENTS 0x70 /* remove tuples from one page
35 * and add to another page */
36 #define XLOG_HASH_SQUEEZE_PAGE 0x80 /* add tuples to one of the previous
37 * pages in chain and free the ovfl
39#define XLOG_HASH_DELETE 0x90 /* delete index tuples from a page */
40 #define XLOG_HASH_SPLIT_CLEANUP 0xA0 /* clear split-cleanup flag in primary
41 * bucket page after deleting tuples
42 * that are moved due to split */
43#define XLOG_HASH_UPDATE_META_PAGE 0xB0 /* update meta page after vacuum */
45 #define XLOG_HASH_VACUUM_ONE_PAGE 0xC0 /* remove dead tuples from index
49 * xl_hash_split_allocate_page flag values, 8 bits are available.
51#define XLH_SPLIT_META_UPDATE_MASKS (1<<0)
52#define XLH_SPLIT_META_UPDATE_SPLITPOINT (1<<1)
55 * This is what we need to know about simple (without split) insert.
57 * This data record is used for XLOG_HASH_INSERT
59 * Backup Blk 0: original page (data contains the inserted tuple)
60 * Backup Blk 1: metapage (HashMetaPageData)
67#define SizeOfHashInsert (offsetof(xl_hash_insert, offnum) + sizeof(OffsetNumber))
70 * This is what we need to know about addition of overflow page.
72 * This data record is used for XLOG_HASH_ADD_OVFL_PAGE
74 * Backup Blk 0: newly allocated overflow page
75 * Backup Blk 1: page before new overflow page in the bucket chain
76 * Backup Blk 2: bitmap page
77 * Backup Blk 3: new bitmap page
78 * Backup Blk 4: metapage
86#define SizeOfHashAddOvflPage \
87 (offsetof(xl_hash_add_ovfl_page, bmpage_found) + sizeof(bool))
90 * This is what we need to know about allocating a page for split.
92 * This data record is used for XLOG_HASH_SPLIT_ALLOCATE_PAGE
94 * Backup Blk 0: page for old bucket
95 * Backup Blk 1: page for new bucket
96 * Backup Blk 2: metapage
106#define SizeOfHashSplitAllocPage \
107 (offsetof(xl_hash_split_allocate_page, flags) + sizeof(uint8))
110 * This is what we need to know about completing the split operation.
112 * This data record is used for XLOG_HASH_SPLIT_COMPLETE
114 * Backup Blk 0: page for old bucket
115 * Backup Blk 1: page for new bucket
123#define SizeOfHashSplitComplete \
124 (offsetof(xl_hash_split_complete, new_bucket_flag) + sizeof(uint16))
127 * This is what we need to know about move page contents required during
130 * This data record is used for XLOG_HASH_MOVE_PAGE_CONTENTS
132 * Backup Blk 0: primary bucket page
133 * Backup Blk 1: page containing moved tuples
134 * Backup Blk 2: page from which tuples will be removed
140 * tuples are moved is same as
141 * primary bucket page */
144#define SizeOfHashMovePageContents \
145 (offsetof(xl_hash_move_page_contents, is_prim_bucket_same_wrt) + sizeof(bool))
148 * This is what we need to know about the squeeze page operation.
150 * This data record is used for XLOG_HASH_SQUEEZE_PAGE
152 * Backup Blk 0: primary bucket page
153 * Backup Blk 1: page containing tuples moved from freed overflow page
154 * Backup Blk 2: freed overflow page
155 * Backup Blk 3: page previous to the freed overflow page
156 * Backup Blk 4: page next to the freed overflow page
157 * Backup Blk 5: bitmap page containing info of freed overflow page
158 * Backup Blk 6: meta page
166 * tuples are moved is same as
167 * primary bucket page */
169 * tuples are moved is the page
170 * previous to the freed overflow
174#define SizeOfHashSqueezePage \
175 (offsetof(xl_hash_squeeze_page, is_prev_bucket_same_wrt) + sizeof(bool))
178 * This is what we need to know about the deletion of index tuples from a page.
180 * This data record is used for XLOG_HASH_DELETE
182 * Backup Blk 0: primary bucket page
183 * Backup Blk 1: page from which tuples are deleted
188 * LH_PAGE_HAS_DEAD_TUPLES flag */
190 * primary bucket page */
193#define SizeOfHashDelete (offsetof(xl_hash_delete, is_primary_bucket_page) + sizeof(bool))
196 * This is what we need for metapage update operation.
198 * This data record is used for XLOG_HASH_UPDATE_META_PAGE
200 * Backup Blk 0: meta page
207#define SizeOfHashUpdateMetaPage \
208 (offsetof(xl_hash_update_meta_page, ntuples) + sizeof(double))
211 * This is what we need to initialize metapage.
213 * This data record is used for XLOG_HASH_INIT_META_PAGE
215 * Backup Blk 0: meta page
224#define SizeOfHashInitMetaPage \
225 (offsetof(xl_hash_init_meta_page, ffactor) + sizeof(uint16))
228 * This is what we need to initialize bitmap page.
230 * This data record is used for XLOG_HASH_INIT_BITMAP_PAGE
232 * Backup Blk 0: bitmap page
233 * Backup Blk 1: meta page
240#define SizeOfHashInitBitmapPage \
241 (offsetof(xl_hash_init_bitmap_page, bmsize) + sizeof(uint16))
244 * This is what we need for index tuple deletion and to
245 * update the meta page.
247 * This data record is used for XLOG_HASH_VACUUM_ONE_PAGE
249 * Backup Blk 0: primary bucket page
250 * Backup Blk 1: meta page
256 bool isCatalogRel;
/* to handle recovery conflict during logical
257 * decoding on standby */
259 /* TARGET OFFSET NUMBERS */
263#define SizeOfHashVacuumOnePage offsetof(xl_hash_vacuum_one_page, offsets)
270#endif /* HASH_XLOG_H */
#define FLEXIBLE_ARRAY_MEMBER
struct xl_hash_vacuum_one_page xl_hash_vacuum_one_page
struct xl_hash_init_bitmap_page xl_hash_init_bitmap_page
struct xl_hash_delete xl_hash_delete
struct xl_hash_move_page_contents xl_hash_move_page_contents
struct xl_hash_split_complete xl_hash_split_complete
struct xl_hash_squeeze_page xl_hash_squeeze_page
struct xl_hash_init_meta_page xl_hash_init_meta_page
void hash_mask(char *pagedata, BlockNumber blkno)
struct xl_hash_update_meta_page xl_hash_update_meta_page
struct xl_hash_insert xl_hash_insert
const char * hash_identify(uint8 info)
struct xl_hash_add_ovfl_page xl_hash_add_ovfl_page
void hash_desc(StringInfo buf, XLogReaderState *record)
struct xl_hash_split_allocate_page xl_hash_split_allocate_page
void hash_redo(XLogReaderState *record)
bool is_primary_bucket_page
bool is_prim_bucket_same_wrt
bool is_prim_bucket_same_wrt
bool is_prev_bucket_same_wrt
TransactionId snapshotConflictHorizon
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER]