PostgreSQL Source Code git master
brin_xlog.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * brin_xlog.h
4 * POSTGRES BRIN access XLOG definitions.
5 *
6 *
7 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/access/brin_xlog.h
11 *
12 *-------------------------------------------------------------------------
13 */
14#ifndef BRIN_XLOG_H
15#define BRIN_XLOG_H
16
17#include "access/xlogreader.h"
18#include "lib/stringinfo.h"
19#include "storage/bufpage.h"
20#include "storage/itemptr.h"
22#include "utils/relcache.h"
23
24
25/*
26 * WAL record definitions for BRIN's WAL operations
27 *
28 * XLOG allows to store some information in high 4 bits of log
29 * record xl_info field.
30 */
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
37
38#define XLOG_BRIN_OPMASK 0x70
39/*
40 * When we insert the first item on a new page, we restore the entire page in
41 * redo.
42 */
43#define XLOG_BRIN_INIT_PAGE 0x80
44
45/*
46 * This is what we need to know about a BRIN index create.
47 *
48 * Backup block 0: metapage
49 */
50typedef struct xl_brin_createidx
51{
55#define SizeOfBrinCreateIdx (offsetof(xl_brin_createidx, version) + sizeof(uint16))
56
57/*
58 * This is what we need to know about a BRIN tuple insert
59 *
60 * Backup block 0: main page, block data is the new BrinTuple.
61 * Backup block 1: revmap page
62 */
63typedef struct xl_brin_insert
64{
66
67 /* extra information needed to update the revmap */
69
70 /* offset number in the main page to insert the tuple to. */
73
74#define SizeOfBrinInsert (offsetof(xl_brin_insert, offnum) + sizeof(OffsetNumber))
75
76/*
77 * A cross-page update is the same as an insert, but also stores information
78 * about the old tuple.
79 *
80 * Like in xl_brin_insert:
81 * Backup block 0: new page, block data includes the new BrinTuple.
82 * Backup block 1: revmap page
83 *
84 * And in addition:
85 * Backup block 2: old page
86 */
87typedef struct xl_brin_update
88{
89 /* offset number of old tuple on old page */
91
94
95#define SizeOfBrinUpdate (offsetof(xl_brin_update, insert) + SizeOfBrinInsert)
96
97/*
98 * This is what we need to know about a BRIN tuple samepage update
99 *
100 * Backup block 0: updated page, with new BrinTuple as block data
101 */
103{
106
107#define SizeOfBrinSamepageUpdate (sizeof(OffsetNumber))
108
109/*
110 * This is what we need to know about a revmap extension
111 *
112 * Backup block 0: metapage
113 * Backup block 1: new revmap page
114 */
116{
117 /*
118 * XXX: This is actually redundant - the block number is stored as part of
119 * backup block 1.
120 */
123
124#define SizeOfBrinRevmapExtend (offsetof(xl_brin_revmap_extend, targetBlk) + \
125 sizeof(BlockNumber))
126
127/*
128 * This is what we need to know about a range de-summarization
129 *
130 * Backup block 0: revmap page
131 * Backup block 1: regular page
132 */
134{
136 /* page number location to set to invalid */
138 /* offset of item to delete in regular index page */
141
142#define SizeOfBrinDesummarize (offsetof(xl_brin_desummarize, regOffset) + \
143 sizeof(OffsetNumber))
144
145
146extern void brin_redo(XLogReaderState *record);
147extern void brin_desc(StringInfo buf, XLogReaderState *record);
148extern const char *brin_identify(uint8 info);
149extern void brin_mask(char *pagedata, BlockNumber blkno);
150
151#endif /* BRIN_XLOG_H */
uint32 BlockNumber
Definition: block.h:31
void brin_redo(XLogReaderState *record)
Definition: brin_xlog.c:309
struct xl_brin_revmap_extend xl_brin_revmap_extend
void brin_desc(StringInfo buf, XLogReaderState *record)
Definition: brindesc.c:20
const char * brin_identify(uint8 info)
Definition: brindesc.c:74
struct xl_brin_desummarize xl_brin_desummarize
struct xl_brin_samepage_update xl_brin_samepage_update
struct xl_brin_insert xl_brin_insert
void brin_mask(char *pagedata, BlockNumber blkno)
Definition: brin_xlog.c:342
struct xl_brin_update xl_brin_update
struct xl_brin_createidx xl_brin_createidx
uint8_t uint8
Definition: c.h:486
uint16_t uint16
Definition: c.h:487
uint16 OffsetNumber
Definition: off.h:24
static char * buf
Definition: pg_test_fsync.c:72
BlockNumber pagesPerRange
Definition: brin_xlog.h:52
BlockNumber pagesPerRange
Definition: brin_xlog.h:135
BlockNumber heapBlk
Definition: brin_xlog.h:137
OffsetNumber regOffset
Definition: brin_xlog.h:139
OffsetNumber offnum
Definition: brin_xlog.h:71
BlockNumber pagesPerRange
Definition: brin_xlog.h:68
BlockNumber heapBlk
Definition: brin_xlog.h:65
BlockNumber targetBlk
Definition: brin_xlog.h:121
OffsetNumber offnum
Definition: brin_xlog.h:104
OffsetNumber oldOffnum
Definition: brin_xlog.h:90
xl_brin_insert insert
Definition: brin_xlog.h:92