PostgreSQL Source Code  git master
gistxlog.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * gistxlog.h
4  * gist xlog routines
5  *
6  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/access/gistxlog.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef GIST_XLOG_H
14 #define GIST_XLOG_H
15 
16 #include "access/gist.h"
17 #include "access/xlogreader.h"
18 #include "lib/stringinfo.h"
19 
20 #define XLOG_GIST_PAGE_UPDATE 0x00
21 #define XLOG_GIST_DELETE 0x10 /* delete leaf index tuples for a
22  * page */
23 #define XLOG_GIST_PAGE_REUSE 0x20 /* old page is about to be reused
24  * from FSM */
25 #define XLOG_GIST_PAGE_SPLIT 0x30
26  /* #define XLOG_GIST_INSERT_COMPLETE 0x40 */ /* not used anymore */
27  /* #define XLOG_GIST_CREATE_INDEX 0x50 */ /* not used anymore */
28 #define XLOG_GIST_PAGE_DELETE 0x60
29 #define XLOG_GIST_ASSIGN_LSN 0x70 /* nop, assign new LSN */
30 
31 /*
32  * Backup Blk 0: updated page.
33  * Backup Blk 1: If this operation completes a page split, by inserting a
34  * downlink for the split page, the left half of the split
35  */
36 typedef struct gistxlogPageUpdate
37 {
38  /* number of deleted offsets */
41 
42  /*
43  * In payload of blk 0 : 1. todelete OffsetNumbers 2. tuples to insert
44  */
46 
47 /*
48  * Backup Blk 0: Leaf page, whose index tuples are deleted.
49  */
50 typedef struct gistxlogDelete
51 {
53  uint16 ntodelete; /* number of deleted offsets */
54  bool isCatalogRel; /* to handle recovery conflict during logical
55  * decoding on standby */
56 
57  /* TODELETE OFFSET NUMBERS */
60 
61 #define SizeOfGistxlogDelete offsetof(gistxlogDelete, offsets)
62 
63 /*
64  * Backup Blk 0: If this operation completes a page split, by inserting a
65  * downlink for the split page, the left half of the split
66  * Backup Blk 1 - npage: split pages (1 is the original page)
67  */
68 typedef struct gistxlogPageSplit
69 {
70  BlockNumber origrlink; /* rightlink of the page before split */
71  GistNSN orignsn; /* NSN of the page before split */
72  bool origleaf; /* was split page a leaf page? */
73 
74  uint16 npage; /* # of pages in the split */
75  bool markfollowright; /* set F_FOLLOW_RIGHT flags */
76 
77  /*
78  * follow: 1. gistxlogPage and array of IndexTupleData per page
79  */
81 
82 /*
83  * Backup Blk 0: page that was deleted.
84  * Backup Blk 1: parent page, containing the downlink to the deleted page.
85  */
86 typedef struct gistxlogPageDelete
87 {
88  FullTransactionId deleteXid; /* last Xid which could see page in scan */
89  OffsetNumber downlinkOffset; /* Offset of downlink referencing this
90  * page */
92 
93 #define SizeOfGistxlogPageDelete (offsetof(gistxlogPageDelete, downlinkOffset) + sizeof(OffsetNumber))
94 
95 
96 /*
97  * This is what we need to know about page reuse, for hot standby.
98  */
99 typedef struct gistxlogPageReuse
100 {
104  bool isCatalogRel; /* to handle recovery conflict during logical
105  * decoding on standby */
107 
108 #define SizeOfGistxlogPageReuse (offsetof(gistxlogPageReuse, isCatalogRel) + sizeof(bool))
109 
110 extern void gist_redo(XLogReaderState *record);
111 extern void gist_desc(StringInfo buf, XLogReaderState *record);
112 extern const char *gist_identify(uint8 info);
113 extern void gist_xlog_startup(void);
114 extern void gist_xlog_cleanup(void);
115 extern void gist_mask(char *pagedata, BlockNumber blkno);
116 
117 #endif
uint32 BlockNumber
Definition: block.h:31
unsigned short uint16
Definition: c.h:505
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:398
unsigned char uint8
Definition: c.h:504
uint32 TransactionId
Definition: c.h:652
XLogRecPtr GistNSN
Definition: gist.h:62
struct gistxlogPageUpdate gistxlogPageUpdate
struct gistxlogPageSplit gistxlogPageSplit
void gist_xlog_startup(void)
Definition: gistxlog.c:438
void gist_redo(XLogReaderState *record)
Definition: gistxlog.c:397
const char * gist_identify(uint8 info)
Definition: gistdesc.c:90
void gist_desc(StringInfo buf, XLogReaderState *record)
Definition: gistdesc.c:61
struct gistxlogPageReuse gistxlogPageReuse
struct gistxlogDelete gistxlogDelete
struct gistxlogPageDelete gistxlogPageDelete
void gist_xlog_cleanup(void)
Definition: gistxlog.c:444
void gist_mask(char *pagedata, BlockNumber blkno)
Definition: gistxlog.c:453
uint16 OffsetNumber
Definition: off.h:24
static char * buf
Definition: pg_test_fsync.c:73
bool isCatalogRel
Definition: gistxlog.h:52
TransactionId snapshotConflictHorizon
Definition: gistxlog.h:50
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER]
Definition: gistxlog.h:56
uint16 ntodelete
Definition: gistxlog.h:51
FullTransactionId deleteXid
Definition: gistxlog.h:86
OffsetNumber downlinkOffset
Definition: gistxlog.h:87
RelFileLocator locator
Definition: gistxlog.h:99
BlockNumber block
Definition: gistxlog.h:100
FullTransactionId snapshotConflictHorizon
Definition: gistxlog.h:101
GistNSN orignsn
Definition: gistxlog.h:69
BlockNumber origrlink
Definition: gistxlog.h:68
bool markfollowright
Definition: gistxlog.h:73
uint16 ntodelete
Definition: gistxlog.h:37
uint16 ntoinsert
Definition: gistxlog.h:38