PostgreSQL Source Code  git master
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 XLOG_GIST_ASSIGN_LSN   0x70 /* nop, assign new LSN */
 
#define SizeOfGistxlogDelete   (offsetof(gistxlogDelete, ntodelete) + sizeof(uint16))
 
#define SizeOfGistxlogPageDelete   (offsetof(gistxlogPageDelete, downlinkOffset) + sizeof(OffsetNumber))
 
#define SizeOfGistxlogPageReuse   (offsetof(gistxlogPageReuse, latestRemovedFullXid) + sizeof(FullTransactionId))
 

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 char * gist_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, ntodelete) + sizeof(uint16))

Definition at line 58 of file gistxlog.h.

◆ SizeOfGistxlogPageDelete

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

Definition at line 90 of file gistxlog.h.

◆ SizeOfGistxlogPageReuse

#define SizeOfGistxlogPageReuse   (offsetof(gistxlogPageReuse, latestRemovedFullXid) + sizeof(FullTransactionId))

Definition at line 103 of file gistxlog.h.

◆ XLOG_GIST_ASSIGN_LSN

#define XLOG_GIST_ASSIGN_LSN   0x70 /* nop, assign new LSN */

Definition at line 27 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.

◆ 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 
)

Definition at line 60 of file gistdesc.c.

61 {
62  char *rec = XLogRecGetData(record);
63  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
64 
65  switch (info)
66  {
69  break;
72  break;
73  case XLOG_GIST_DELETE:
75  break;
78  break;
81  break;
83  /* No details to write out */
84  break;
85  }
86 }
unsigned char uint8
Definition: c.h:439
static void out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
Definition: gistdesc.c:51
static void out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
Definition: gistdesc.c:22
static void out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
Definition: gistdesc.c:44
static void out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
Definition: gistdesc.c:37
static void out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
Definition: gistdesc.c:27
#define XLOG_GIST_ASSIGN_LSN
Definition: gistxlog.h:27
#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
static char * buf
Definition: pg_test_fsync.c:67
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:408
#define XLogRecGetData(decoder)
Definition: xlogreader.h:413
#define XLR_INFO_MASK
Definition: xlogrecord.h:62

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

◆ gist_identify()

const char* gist_identify ( uint8  info)

Definition at line 89 of file gistdesc.c.

90 {
91  const char *id = NULL;
92 
93  switch (info & ~XLR_INFO_MASK)
94  {
96  id = "PAGE_UPDATE";
97  break;
98  case XLOG_GIST_DELETE:
99  id = "DELETE";
100  break;
102  id = "PAGE_REUSE";
103  break;
105  id = "PAGE_SPLIT";
106  break;
108  id = "PAGE_DELETE";
109  break;
111  id = "ASSIGN_LSN";
112  break;
113  }
114 
115  return id;
116 }

References XLOG_GIST_ASSIGN_LSN, 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 
)

Definition at line 458 of file gistxlog.c.

459 {
460  Page page = (Page) pagedata;
461 
463 
464  mask_page_hint_bits(page);
465  mask_unused_space(page);
466 
467  /*
468  * NSN is nothing but a special purpose LSN. Hence, mask it for the same
469  * reason as mask_page_lsn_and_checksum.
470  */
471  GistPageSetNSN(page, (uint64) MASK_MARKER);
472 
473  /*
474  * We update F_FOLLOW_RIGHT flag on the left child after writing WAL
475  * record. Hence, mask this flag. See gistplacetopage() for details.
476  */
477  GistMarkFollowRight(page);
478 
479  if (GistPageIsLeaf(page))
480  {
481  /*
482  * In gist leaf pages, it is possible to modify the LP_FLAGS without
483  * emitting any WAL record. Hence, mask the line pointer flags. See
484  * gistkillitems() for details.
485  */
486  mask_lp_flags(page);
487  }
488 
489  /*
490  * During gist redo, we never mark a page as garbage. Hence, mask it to
491  * ignore any differences.
492  */
494 }
void mask_lp_flags(Page page)
Definition: bufmask.c:95
void mask_page_lsn_and_checksum(Page page)
Definition: bufmask.c:31
void mask_unused_space(Page page)
Definition: bufmask.c:71
void mask_page_hint_bits(Page page)
Definition: bufmask.c:46
#define MASK_MARKER
Definition: bufmask.h:24
Pointer Page
Definition: bufpage.h:78
#define GistMarkFollowRight(page)
Definition: gist.h:181
#define GistClearPageHasGarbage(page)
Definition: gist.h:178
#define GistPageIsLeaf(page)
Definition: gist.h:167
#define GistPageSetNSN(page, val)
Definition: gist.h:185

References 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)

Definition at line 402 of file gistxlog.c.

403 {
404  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
405  MemoryContext oldCxt;
406 
407  /*
408  * GiST indexes do not require any conflict processing. NB: If we ever
409  * implement a similar optimization we have in b-tree, and remove killed
410  * tuples outside VACUUM, we'll need to handle that here.
411  */
412 
413  oldCxt = MemoryContextSwitchTo(opCtx);
414  switch (info)
415  {
417  gistRedoPageUpdateRecord(record);
418  break;
419  case XLOG_GIST_DELETE:
420  gistRedoDeleteRecord(record);
421  break;
423  gistRedoPageReuse(record);
424  break;
426  gistRedoPageSplitRecord(record);
427  break;
429  gistRedoPageDelete(record);
430  break;
432  /* nop. See gistGetFakeLSN(). */
433  break;
434  default:
435  elog(PANIC, "gist_redo: unknown op code %u", info);
436  }
437 
438  MemoryContextSwitchTo(oldCxt);
440 }
#define PANIC
Definition: elog.h:36
#define elog(elevel,...)
Definition: elog.h:218
static void gistRedoPageReuse(XLogReaderState *record)
Definition: gistxlog.c:382
static void gistRedoPageUpdateRecord(XLogReaderState *record)
Definition: gistxlog.c:72
static void gistRedoPageSplitRecord(XLogReaderState *record)
Definition: gistxlog.c:253
static void gistRedoPageDelete(XLogReaderState *record)
Definition: gistxlog.c:348
static void gistRedoDeleteRecord(XLogReaderState *record)
Definition: gistxlog.c:174
static MemoryContext opCtx
Definition: gistxlog.c:28
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:143
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109

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

◆ gist_xlog_cleanup()

void gist_xlog_cleanup ( void  )

Definition at line 449 of file gistxlog.c.

450 {
452 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:218

References MemoryContextDelete(), and opCtx.

◆ gist_xlog_startup()

void gist_xlog_startup ( void  )

Definition at line 443 of file gistxlog.c.

444 {
446 }
MemoryContext createTempGistContext(void)
Definition: gist.c:121

References createTempGistContext(), and opCtx.