Consistently use "superuser" instead of "super user"
[pgsql.git] / src / include / access / brin_xlog.h
blobace8aa0dcdcf570ee8ae78a994ac881df5e08713
1 /*-------------------------------------------------------------------------
3 * brin_xlog.h
4 * POSTGRES BRIN access XLOG definitions.
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/brin_xlog.h
12 *-------------------------------------------------------------------------
14 #ifndef BRIN_XLOG_H
15 #define BRIN_XLOG_H
17 #include "access/xlogreader.h"
18 #include "lib/stringinfo.h"
19 #include "storage/bufpage.h"
20 #include "storage/itemptr.h"
21 #include "storage/relfilenode.h"
22 #include "utils/relcache.h"
26 * WAL record definitions for BRIN's WAL operations
28 * XLOG allows to store some information in high 4 bits of log
29 * record xl_info field.
31 #define XLOG_BRIN_CREATE_INDEX 0x00
32 #define XLOG_BRIN_INSERT 0x10
33 #define XLOG_BRIN_UPDATE 0x20
34 #define XLOG_BRIN_SAMEPAGE_UPDATE 0x30
35 #define XLOG_BRIN_REVMAP_EXTEND 0x40
36 #define XLOG_BRIN_DESUMMARIZE 0x50
38 #define XLOG_BRIN_OPMASK 0x70
40 * When we insert the first item on a new page, we restore the entire page in
41 * redo.
43 #define XLOG_BRIN_INIT_PAGE 0x80
46 * This is what we need to know about a BRIN index create.
48 * Backup block 0: metapage
50 typedef struct xl_brin_createidx
52 BlockNumber pagesPerRange;
53 uint16 version;
54 } xl_brin_createidx;
55 #define SizeOfBrinCreateIdx (offsetof(xl_brin_createidx, version) + sizeof(uint16))
58 * This is what we need to know about a BRIN tuple insert
60 * Backup block 0: main page, block data is the new BrinTuple.
61 * Backup block 1: revmap page
63 typedef struct xl_brin_insert
65 BlockNumber heapBlk;
67 /* extra information needed to update the revmap */
68 BlockNumber pagesPerRange;
70 /* offset number in the main page to insert the tuple to. */
71 OffsetNumber offnum;
72 } xl_brin_insert;
74 #define SizeOfBrinInsert (offsetof(xl_brin_insert, offnum) + sizeof(OffsetNumber))
77 * A cross-page update is the same as an insert, but also stores information
78 * about the old tuple.
80 * Like in xl_brin_insert:
81 * Backup block 0: new page, block data includes the new BrinTuple.
82 * Backup block 1: revmap page
84 * And in addition:
85 * Backup block 2: old page
87 typedef struct xl_brin_update
89 /* offset number of old tuple on old page */
90 OffsetNumber oldOffnum;
92 xl_brin_insert insert;
93 } xl_brin_update;
95 #define SizeOfBrinUpdate (offsetof(xl_brin_update, insert) + SizeOfBrinInsert)
98 * This is what we need to know about a BRIN tuple samepage update
100 * Backup block 0: updated page, with new BrinTuple as block data
102 typedef struct xl_brin_samepage_update
104 OffsetNumber offnum;
105 } xl_brin_samepage_update;
107 #define SizeOfBrinSamepageUpdate (sizeof(OffsetNumber))
110 * This is what we need to know about a revmap extension
112 * Backup block 0: metapage
113 * Backup block 1: new revmap page
115 typedef struct xl_brin_revmap_extend
118 * XXX: This is actually redundant - the block number is stored as part of
119 * backup block 1.
121 BlockNumber targetBlk;
122 } xl_brin_revmap_extend;
124 #define SizeOfBrinRevmapExtend (offsetof(xl_brin_revmap_extend, targetBlk) + \
125 sizeof(BlockNumber))
128 * This is what we need to know about a range de-summarization
130 * Backup block 0: revmap page
131 * Backup block 1: regular page
133 typedef struct xl_brin_desummarize
135 BlockNumber pagesPerRange;
136 /* page number location to set to invalid */
137 BlockNumber heapBlk;
138 /* offset of item to delete in regular index page */
139 OffsetNumber regOffset;
140 } xl_brin_desummarize;
142 #define SizeOfBrinDesummarize (offsetof(xl_brin_desummarize, regOffset) + \
143 sizeof(OffsetNumber))
146 extern void brin_redo(XLogReaderState *record);
147 extern void brin_desc(StringInfo buf, XLogReaderState *record);
148 extern const char *brin_identify(uint8 info);
149 extern void brin_mask(char *pagedata, BlockNumber blkno);
151 #endif /* BRIN_XLOG_H */