| 1 | /*------------------------------------------------------------------------- |
| 2 | * |
| 3 | * gistxlog.h |
| 4 | * gist xlog routines |
| 5 | * |
| 6 | * Portions Copyright (c) 1996-2019, 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 | |
| 30 | /* |
| 31 | * Backup Blk 0: updated page. |
| 32 | * Backup Blk 1: If this operation completes a page split, by inserting a |
| 33 | * downlink for the split page, the left half of the split |
| 34 | */ |
| 35 | typedef struct gistxlogPageUpdate |
| 36 | { |
| 37 | /* number of deleted offsets */ |
| 38 | uint16 ntodelete; |
| 39 | uint16 ntoinsert; |
| 40 | |
| 41 | /* |
| 42 | * In payload of blk 0 : 1. todelete OffsetNumbers 2. tuples to insert |
| 43 | */ |
| 44 | } gistxlogPageUpdate; |
| 45 | |
| 46 | /* |
| 47 | * Backup Blk 0: Leaf page, whose index tuples are deleted. |
| 48 | */ |
| 49 | typedef struct gistxlogDelete |
| 50 | { |
| 51 | TransactionId latestRemovedXid; |
| 52 | uint16 ntodelete; /* number of deleted offsets */ |
| 53 | |
| 54 | /* |
| 55 | * In payload of blk 0 : todelete OffsetNumbers |
| 56 | */ |
| 57 | } gistxlogDelete; |
| 58 | |
| 59 | #define SizeOfGistxlogDelete (offsetof(gistxlogDelete, ntodelete) + sizeof(uint16)) |
| 60 | |
| 61 | /* |
| 62 | * Backup Blk 0: If this operation completes a page split, by inserting a |
| 63 | * downlink for the split page, the left half of the split |
| 64 | * Backup Blk 1 - npage: split pages (1 is the original page) |
| 65 | */ |
| 66 | typedef struct gistxlogPageSplit |
| 67 | { |
| 68 | BlockNumber origrlink; /* rightlink of the page before split */ |
| 69 | GistNSN orignsn; /* NSN of the page before split */ |
| 70 | bool origleaf; /* was splitted page a leaf page? */ |
| 71 | |
| 72 | uint16 npage; /* # of pages in the split */ |
| 73 | bool markfollowright; /* set F_FOLLOW_RIGHT flags */ |
| 74 | |
| 75 | /* |
| 76 | * follow: 1. gistxlogPage and array of IndexTupleData per page |
| 77 | */ |
| 78 | } gistxlogPageSplit; |
| 79 | |
| 80 | /* |
| 81 | * Backup Blk 0: page that was deleted. |
| 82 | * Backup Blk 1: parent page, containing the downlink to the deleted page. |
| 83 | */ |
| 84 | typedef struct gistxlogPageDelete |
| 85 | { |
| 86 | FullTransactionId deleteXid; /* last Xid which could see page in scan */ |
| 87 | OffsetNumber downlinkOffset; /* Offset of downlink referencing this |
| 88 | * page */ |
| 89 | } gistxlogPageDelete; |
| 90 | |
| 91 | #define SizeOfGistxlogPageDelete (offsetof(gistxlogPageDelete, downlinkOffset) + sizeof(OffsetNumber)) |
| 92 | |
| 93 | |
| 94 | /* |
| 95 | * This is what we need to know about page reuse, for hot standby. |
| 96 | */ |
| 97 | typedef struct |
| 98 | { |
| 99 | RelFileNode ; |
| 100 | BlockNumber ; |
| 101 | FullTransactionId ; |
| 102 | } ; |
| 103 | |
| 104 | #define (offsetof(gistxlogPageReuse, latestRemovedFullXid) + sizeof(FullTransactionId)) |
| 105 | |
| 106 | extern void gist_redo(XLogReaderState *record); |
| 107 | extern void gist_desc(StringInfo buf, XLogReaderState *record); |
| 108 | extern const char *gist_identify(uint8 info); |
| 109 | extern void gist_xlog_startup(void); |
| 110 | extern void gist_xlog_cleanup(void); |
| 111 | extern void gist_mask(char *pagedata, BlockNumber blkno); |
| 112 | |
| 113 | #endif |
| 114 | |