PostgreSQL Source Code git master
Loading...
Searching...
No Matches
gistxlog.h File Reference
#include "access/gist.h"
#include "access/xlogreader.h"
#include "lib/stringinfo.h"
Include dependency graph for gistxlog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  gistxlogPageUpdate
 
struct  gistxlogDelete
 
struct  gistxlogPageSplit
 
struct  gistxlogPageDelete
 
struct  gistxlogPageReuse
 

Macros

#define XLOG_GIST_PAGE_UPDATE   0x00
 
#define XLOG_GIST_DELETE
 
#define XLOG_GIST_PAGE_REUSE
 
#define XLOG_GIST_PAGE_SPLIT   0x30
 
#define XLOG_GIST_PAGE_DELETE   0x60
 
#define SizeOfGistxlogDelete   offsetof(gistxlogDelete, offsets)
 
#define SizeOfGistxlogPageDelete   (offsetof(gistxlogPageDelete, downlinkOffset) + sizeof(OffsetNumber))
 
#define SizeOfGistxlogPageReuse   (offsetof(gistxlogPageReuse, isCatalogRel) + sizeof(bool))
 

Typedefs

typedef struct gistxlogPageUpdate gistxlogPageUpdate
 
typedef struct gistxlogDelete gistxlogDelete
 
typedef struct gistxlogPageSplit gistxlogPageSplit
 
typedef struct gistxlogPageDelete gistxlogPageDelete
 
typedef struct gistxlogPageReuse gistxlogPageReuse
 

Functions

void gist_redo (XLogReaderState *record)
 
void gist_desc (StringInfo buf, XLogReaderState *record)
 
const chargist_identify (uint8 info)
 
void gist_xlog_startup (void)
 
void gist_xlog_cleanup (void)
 
void gist_mask (char *pagedata, BlockNumber blkno)
 

Macro Definition Documentation

◆ SizeOfGistxlogDelete

#define SizeOfGistxlogDelete   offsetof(gistxlogDelete, offsets)

Definition at line 59 of file gistxlog.h.

◆ SizeOfGistxlogPageDelete

#define SizeOfGistxlogPageDelete   (offsetof(gistxlogPageDelete, downlinkOffset) + sizeof(OffsetNumber))

Definition at line 91 of file gistxlog.h.

◆ SizeOfGistxlogPageReuse

#define SizeOfGistxlogPageReuse   (offsetof(gistxlogPageReuse, isCatalogRel) + sizeof(bool))

Definition at line 106 of file gistxlog.h.

◆ XLOG_GIST_DELETE

#define XLOG_GIST_DELETE
Value:
0x10 /* delete leaf index tuples for a
* page */

Definition at line 21 of file gistxlog.h.

37{
38 /* number of deleted offsets */
39 uint16 ntodelete;
40 uint16 ntoinsert;
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 */
50typedef 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 */
68typedef 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 */
86typedef 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 */
99typedef 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
110extern void gist_redo(XLogReaderState *record);
111extern void gist_desc(StringInfo buf, XLogReaderState *record);
112extern const char *gist_identify(uint8 info);
113extern void gist_xlog_startup(void);
114extern void gist_xlog_cleanup(void);
115extern void gist_mask(char *pagedata, BlockNumber blkno);
116
117#endif
uint32 BlockNumber
Definition block.h:31
uint8_t uint8
Definition c.h:616
#define FLEXIBLE_ARRAY_MEMBER
Definition c.h:552
uint16_t uint16
Definition c.h:617
uint32 TransactionId
Definition c.h:738
XLogRecPtr GistNSN
Definition gist.h:63
void gist_xlog_startup(void)
Definition gistxlog.c:433
void gist_redo(XLogReaderState *record)
Definition gistxlog.c:395
void gist_desc(StringInfo buf, XLogReaderState *record)
Definition gistdesc.c:61
const char * gist_identify(uint8 info)
Definition gistdesc.c:87
void gist_xlog_cleanup(void)
Definition gistxlog.c:439
void gist_mask(char *pagedata, BlockNumber blkno)
Definition gistxlog.c:448
uint16 OffsetNumber
Definition off.h:24
static char buf[DEFAULT_XLOG_SEG_SIZE]
static int fb(int x)
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

◆ XLOG_GIST_PAGE_DELETE

#define XLOG_GIST_PAGE_DELETE   0x60

Definition at line 26 of file gistxlog.h.

◆ XLOG_GIST_PAGE_REUSE

#define XLOG_GIST_PAGE_REUSE
Value:
0x20 /* old page is about to be reused
* from FSM */

Definition at line 22 of file gistxlog.h.

◆ XLOG_GIST_PAGE_SPLIT

#define XLOG_GIST_PAGE_SPLIT   0x30

Definition at line 23 of file gistxlog.h.

◆ XLOG_GIST_PAGE_UPDATE

#define XLOG_GIST_PAGE_UPDATE   0x00

Definition at line 20 of file gistxlog.h.

Typedef Documentation

◆ gistxlogDelete

◆ gistxlogPageDelete

◆ gistxlogPageReuse

◆ gistxlogPageSplit

◆ gistxlogPageUpdate

Function Documentation

◆ gist_desc()

void gist_desc ( StringInfo  buf,
XLogReaderState record 
)
extern

Definition at line 61 of file gistdesc.c.

62{
63 char *rec = XLogRecGetData(record);
64 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
65
66 switch (info)
67 {
70 break;
73 break;
76 break;
79 break;
82 break;
83 }
84}
static void out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
Definition gistdesc.c:52
static void out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
Definition gistdesc.c:21
static void out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
Definition gistdesc.c:45
static void out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
Definition gistdesc.c:37
static void out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
Definition gistdesc.c:26
#define XLOG_GIST_PAGE_REUSE
Definition gistxlog.h:22
#define XLOG_GIST_PAGE_DELETE
Definition gistxlog.h:26
#define XLOG_GIST_DELETE
Definition gistxlog.h:21
#define XLOG_GIST_PAGE_SPLIT
Definition gistxlog.h:23
#define XLOG_GIST_PAGE_UPDATE
Definition gistxlog.h:20
#define XLogRecGetInfo(decoder)
Definition xlogreader.h:410
#define XLogRecGetData(decoder)
Definition xlogreader.h:415

References buf, fb(), out_gistxlogDelete(), out_gistxlogPageDelete(), out_gistxlogPageReuse(), out_gistxlogPageSplit(), out_gistxlogPageUpdate(), XLOG_GIST_DELETE, XLOG_GIST_PAGE_DELETE, XLOG_GIST_PAGE_REUSE, XLOG_GIST_PAGE_SPLIT, XLOG_GIST_PAGE_UPDATE, XLogRecGetData, and XLogRecGetInfo.

◆ gist_identify()

const char * gist_identify ( uint8  info)
extern

Definition at line 87 of file gistdesc.c.

88{
89 const char *id = NULL;
90
91 switch (info & ~XLR_INFO_MASK)
92 {
94 id = "PAGE_UPDATE";
95 break;
97 id = "DELETE";
98 break;
100 id = "PAGE_REUSE";
101 break;
103 id = "PAGE_SPLIT";
104 break;
106 id = "PAGE_DELETE";
107 break;
108 }
109
110 return id;
111}
#define XLR_INFO_MASK
Definition xlogrecord.h:62

References fb(), XLOG_GIST_DELETE, XLOG_GIST_PAGE_DELETE, XLOG_GIST_PAGE_REUSE, XLOG_GIST_PAGE_SPLIT, XLOG_GIST_PAGE_UPDATE, and XLR_INFO_MASK.

◆ gist_mask()

void gist_mask ( char pagedata,
BlockNumber  blkno 
)
extern

Definition at line 448 of file gistxlog.c.

449{
450 Page page = (Page) pagedata;
451
453
455 mask_unused_space(page);
456
457 /*
458 * NSN is nothing but a special purpose LSN. Hence, mask it for the same
459 * reason as mask_page_lsn_and_checksum.
460 */
462
463 /*
464 * We update F_FOLLOW_RIGHT flag on the left child after writing WAL
465 * record. Hence, mask this flag. See gistplacetopage() for details.
466 */
468
469 if (GistPageIsLeaf(page))
470 {
471 /*
472 * In gist leaf pages, it is possible to modify the LP_FLAGS without
473 * emitting any WAL record. Hence, mask the line pointer flags. See
474 * gistkillitems() for details.
475 */
476 mask_lp_flags(page);
477 }
478
479 /*
480 * During gist redo, we never mark a page as garbage. Hence, mask it to
481 * ignore any differences.
482 */
484}
void mask_lp_flags(Page page)
Definition bufmask.c:94
void mask_page_lsn_and_checksum(Page page)
Definition bufmask.c:31
void mask_unused_space(Page page)
Definition bufmask.c:70
void mask_page_hint_bits(Page page)
Definition bufmask.c:46
#define MASK_MARKER
Definition bufmask.h:24
PageData * Page
Definition bufpage.h:81
uint64_t uint64
Definition c.h:619
#define GistMarkFollowRight(page)
Definition gist.h:184
#define GistClearPageHasGarbage(page)
Definition gist.h:181
#define GistPageIsLeaf(page)
Definition gist.h:170
#define GistPageSetNSN(page, val)
Definition gist.h:188

References fb(), GistClearPageHasGarbage, GistMarkFollowRight, GistPageIsLeaf, GistPageSetNSN, mask_lp_flags(), MASK_MARKER, mask_page_hint_bits(), mask_page_lsn_and_checksum(), and mask_unused_space().

◆ gist_redo()

void gist_redo ( XLogReaderState record)
extern

Definition at line 395 of file gistxlog.c.

396{
397 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
399
400 /*
401 * GiST indexes do not require any conflict processing. NB: If we ever
402 * implement a similar optimization we have in b-tree, and remove killed
403 * tuples outside VACUUM, we'll need to handle that here.
404 */
405
407 switch (info)
408 {
411 break;
412 case XLOG_GIST_DELETE:
413 gistRedoDeleteRecord(record);
414 break;
416 gistRedoPageReuse(record);
417 break;
420 break;
422 gistRedoPageDelete(record);
423 break;
424 default:
425 elog(PANIC, "gist_redo: unknown op code %u", info);
426 }
427
430}
#define PANIC
Definition elog.h:42
#define elog(elevel,...)
Definition elog.h:226
static void gistRedoPageReuse(XLogReaderState *record)
Definition gistxlog.c:374
static void gistRedoPageUpdateRecord(XLogReaderState *record)
Definition gistxlog.c:70
static void gistRedoPageSplitRecord(XLogReaderState *record)
Definition gistxlog.c:245
static void gistRedoPageDelete(XLogReaderState *record)
Definition gistxlog.c:340
static void gistRedoDeleteRecord(XLogReaderState *record)
Definition gistxlog.c:170
static MemoryContext opCtx
Definition gistxlog.c:26
void MemoryContextReset(MemoryContext context)
Definition mcxt.c:403
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:124

References elog, fb(), gistRedoDeleteRecord(), gistRedoPageDelete(), gistRedoPageReuse(), gistRedoPageSplitRecord(), gistRedoPageUpdateRecord(), MemoryContextReset(), MemoryContextSwitchTo(), opCtx, PANIC, XLOG_GIST_DELETE, XLOG_GIST_PAGE_DELETE, XLOG_GIST_PAGE_REUSE, XLOG_GIST_PAGE_SPLIT, XLOG_GIST_PAGE_UPDATE, and XLogRecGetInfo.

◆ gist_xlog_cleanup()

void gist_xlog_cleanup ( void  )
extern

Definition at line 439 of file gistxlog.c.

440{
442}
void MemoryContextDelete(MemoryContext context)
Definition mcxt.c:472

References MemoryContextDelete(), and opCtx.

◆ gist_xlog_startup()

void gist_xlog_startup ( void  )
extern

Definition at line 433 of file gistxlog.c.

434{
436}
MemoryContext createTempGistContext(void)
Definition gist.c:129

References createTempGistContext(), and opCtx.