Consistently use "superuser" instead of "super user"
[pgsql.git] / src / include / access / hash_xlog.h
blob4353a32dbbaee16ab0af5818ade9ed0a670cf4a3
1 /*-------------------------------------------------------------------------
3 * hash_xlog.h
4 * header file for Postgres hash AM implementation
7 * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/access/hash_xlog.h
12 *-------------------------------------------------------------------------
14 #ifndef HASH_XLOG_H
15 #define HASH_XLOG_H
17 #include "access/xlogreader.h"
18 #include "lib/stringinfo.h"
19 #include "storage/off.h"
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
38 * page */
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
46 * page */
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)
62 typedef struct xl_hash_insert
64 OffsetNumber offnum;
65 } xl_hash_insert;
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
80 typedef struct xl_hash_add_ovfl_page
82 uint16 bmsize;
83 bool bmpage_found;
84 } xl_hash_add_ovfl_page;
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
98 typedef struct xl_hash_split_allocate_page
100 uint32 new_bucket;
101 uint16 old_bucket_flag;
102 uint16 new_bucket_flag;
103 uint8 flags;
104 } xl_hash_split_allocate_page;
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
117 typedef struct xl_hash_split_complete
119 uint16 old_bucket_flag;
120 uint16 new_bucket_flag;
121 } xl_hash_split_complete;
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
128 * squeeze operation.
130 * This data record is used for XLOG_HASH_MOVE_PAGE_CONTENTS
132 * Backup Blk 0: bucket page
133 * Backup Blk 1: page containing moved tuples
134 * Backup Blk 2: page from which tuples will be removed
136 typedef struct xl_hash_move_page_contents
138 uint16 ntups;
139 bool is_prim_bucket_same_wrt; /* true if the page to which
140 * tuples are moved is same as
141 * primary bucket page */
142 } xl_hash_move_page_contents;
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: page containing tuples moved from freed overflow page
153 * Backup Blk 1: freed overflow page
154 * Backup Blk 2: page previous to the freed overflow page
155 * Backup Blk 3: page next to the freed overflow page
156 * Backup Blk 4: bitmap page containing info of freed overflow page
157 * Backup Blk 5: meta page
159 typedef struct xl_hash_squeeze_page
161 BlockNumber prevblkno;
162 BlockNumber nextblkno;
163 uint16 ntups;
164 bool is_prim_bucket_same_wrt; /* true if the page to which
165 * tuples are moved is same as
166 * primary bucket page */
167 bool is_prev_bucket_same_wrt; /* true if the page to which
168 * tuples are moved is the page
169 * previous to the freed overflow
170 * page */
171 } xl_hash_squeeze_page;
173 #define SizeOfHashSqueezePage \
174 (offsetof(xl_hash_squeeze_page, is_prev_bucket_same_wrt) + sizeof(bool))
177 * This is what we need to know about the deletion of index tuples from a page.
179 * This data record is used for XLOG_HASH_DELETE
181 * Backup Blk 0: primary bucket page
182 * Backup Blk 1: page from which tuples are deleted
184 typedef struct xl_hash_delete
186 bool clear_dead_marking; /* true if this operation clears
187 * LH_PAGE_HAS_DEAD_TUPLES flag */
188 bool is_primary_bucket_page; /* true if the operation is for
189 * primary bucket page */
190 } xl_hash_delete;
192 #define SizeOfHashDelete (offsetof(xl_hash_delete, is_primary_bucket_page) + sizeof(bool))
195 * This is what we need for metapage update operation.
197 * This data record is used for XLOG_HASH_UPDATE_META_PAGE
199 * Backup Blk 0: meta page
201 typedef struct xl_hash_update_meta_page
203 double ntuples;
204 } xl_hash_update_meta_page;
206 #define SizeOfHashUpdateMetaPage \
207 (offsetof(xl_hash_update_meta_page, ntuples) + sizeof(double))
210 * This is what we need to initialize metapage.
212 * This data record is used for XLOG_HASH_INIT_META_PAGE
214 * Backup Blk 0: meta page
216 typedef struct xl_hash_init_meta_page
218 double num_tuples;
219 RegProcedure procid;
220 uint16 ffactor;
221 } xl_hash_init_meta_page;
223 #define SizeOfHashInitMetaPage \
224 (offsetof(xl_hash_init_meta_page, ffactor) + sizeof(uint16))
227 * This is what we need to initialize bitmap page.
229 * This data record is used for XLOG_HASH_INIT_BITMAP_PAGE
231 * Backup Blk 0: bitmap page
232 * Backup Blk 1: meta page
234 typedef struct xl_hash_init_bitmap_page
236 uint16 bmsize;
237 } xl_hash_init_bitmap_page;
239 #define SizeOfHashInitBitmapPage \
240 (offsetof(xl_hash_init_bitmap_page, bmsize) + sizeof(uint16))
243 * This is what we need for index tuple deletion and to
244 * update the meta page.
246 * This data record is used for XLOG_HASH_VACUUM_ONE_PAGE
248 * Backup Blk 0: bucket page
249 * Backup Blk 1: meta page
251 typedef struct xl_hash_vacuum_one_page
253 TransactionId latestRemovedXid;
254 int ntuples;
256 /* TARGET OFFSET NUMBERS FOLLOW AT THE END */
257 } xl_hash_vacuum_one_page;
259 #define SizeOfHashVacuumOnePage \
260 (offsetof(xl_hash_vacuum_one_page, ntuples) + sizeof(int))
262 extern void hash_redo(XLogReaderState *record);
263 extern void hash_desc(StringInfo buf, XLogReaderState *record);
264 extern const char *hash_identify(uint8 info);
265 extern void hash_mask(char *pagedata, BlockNumber blkno);
267 #endif /* HASH_XLOG_H */