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 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 59 of file gistxlog.h.

Referenced by gistRedoDeleteRecord(), and gistXLogDelete().

◆ SizeOfGistxlogPageDelete

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

Definition at line 91 of file gistxlog.h.

Referenced by gistXLogPageDelete().

◆ SizeOfGistxlogPageReuse

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

Definition at line 104 of file gistxlog.h.

Referenced by gistXLogPageReuse().

◆ XLOG_GIST_DELETE

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

Definition at line 21 of file gistxlog.h.

Referenced by gist_desc(), gist_identify(), gist_redo(), and gistXLogDelete().

◆ XLOG_GIST_PAGE_DELETE

#define XLOG_GIST_PAGE_DELETE   0x60

Definition at line 28 of file gistxlog.h.

Referenced by gist_desc(), gist_identify(), gist_redo(), and gistXLogPageDelete().

◆ XLOG_GIST_PAGE_REUSE

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

Definition at line 23 of file gistxlog.h.

Referenced by gist_desc(), gist_identify(), gist_redo(), and gistXLogPageReuse().

◆ XLOG_GIST_PAGE_SPLIT

#define XLOG_GIST_PAGE_SPLIT   0x30

Definition at line 25 of file gistxlog.h.

Referenced by gist_desc(), gist_identify(), gist_redo(), and gistXLogSplit().

◆ XLOG_GIST_PAGE_UPDATE

#define XLOG_GIST_PAGE_UPDATE   0x00

Definition at line 20 of file gistxlog.h.

Referenced by gist_desc(), gist_identify(), gist_redo(), and gistXLogUpdate().

Typedef Documentation

◆ gistxlogDelete

◆ gistxlogPageDelete

◆ gistxlogPageReuse

◆ gistxlogPageSplit

◆ gistxlogPageUpdate

Function Documentation

◆ gist_desc()

void gist_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 61 of file gistdesc.c.

References 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, XLogRecGetInfo, and XLR_INFO_MASK.

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

◆ gist_identify()

const char* gist_identify ( uint8  info)

Definition at line 87 of file gistdesc.c.

References XLOG_GIST_DELETE, XLOG_GIST_PAGE_DELETE, XLOG_GIST_PAGE_REUSE, XLOG_GIST_PAGE_SPLIT, XLOG_GIST_PAGE_UPDATE, and XLR_INFO_MASK.

88 {
89  const char *id = NULL;
90 
91  switch (info & ~XLR_INFO_MASK)
92  {
94  id = "PAGE_UPDATE";
95  break;
96  case XLOG_GIST_DELETE:
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 XLOG_GIST_PAGE_SPLIT
Definition: gistxlog.h:25
#define XLOG_GIST_DELETE
Definition: gistxlog.h:21
#define XLOG_GIST_PAGE_REUSE
Definition: gistxlog.h:23
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_GIST_PAGE_DELETE
Definition: gistxlog.h:28
#define XLOG_GIST_PAGE_UPDATE
Definition: gistxlog.h:20

◆ gist_mask()

void gist_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 476 of file gistxlog.c.

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

477 {
478  Page page = (Page) pagedata;
479 
481 
482  mask_page_hint_bits(page);
483  mask_unused_space(page);
484 
485  /*
486  * NSN is nothing but a special purpose LSN. Hence, mask it for the same
487  * reason as mask_page_lsn_and_checksum.
488  */
489  GistPageSetNSN(page, (uint64) MASK_MARKER);
490 
491  /*
492  * We update F_FOLLOW_RIGHT flag on the left child after writing WAL
493  * record. Hence, mask this flag. See gistplacetopage() for details.
494  */
495  GistMarkFollowRight(page);
496 
497  if (GistPageIsLeaf(page))
498  {
499  /*
500  * In gist leaf pages, it is possible to modify the LP_FLAGS without
501  * emitting any WAL record. Hence, mask the line pointer flags. See
502  * gistkillitems() for details.
503  */
504  mask_lp_flags(page);
505  }
506 
507  /*
508  * During gist redo, we never mark a page as garbage. Hence, mask it to
509  * ignore any differences.
510  */
512 }
#define GistClearPageHasGarbage(page)
Definition: gist.h:151
void mask_page_hint_bits(Page page)
Definition: bufmask.c:46
#define GistPageSetNSN(page, val)
Definition: gist.h:158
void mask_unused_space(Page page)
Definition: bufmask.c:71
#define MASK_MARKER
Definition: bufmask.h:24
#define GistPageIsLeaf(page)
Definition: gist.h:140
void mask_page_lsn_and_checksum(Page page)
Definition: bufmask.c:31
#define GistMarkFollowRight(page)
Definition: gist.h:154
void mask_lp_flags(Page page)
Definition: bufmask.c:95
Pointer Page
Definition: bufpage.h:78

◆ gist_redo()

void gist_redo ( XLogReaderState record)

Definition at line 423 of file gistxlog.c.

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

424 {
425  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
426  MemoryContext oldCxt;
427 
428  /*
429  * GiST indexes do not require any conflict processing. NB: If we ever
430  * implement a similar optimization we have in b-tree, and remove killed
431  * tuples outside VACUUM, we'll need to handle that here.
432  */
433 
434  oldCxt = MemoryContextSwitchTo(opCtx);
435  switch (info)
436  {
438  gistRedoPageUpdateRecord(record);
439  break;
440  case XLOG_GIST_DELETE:
441  gistRedoDeleteRecord(record);
442  break;
444  gistRedoPageReuse(record);
445  break;
447  gistRedoPageSplitRecord(record);
448  break;
450  gistRedoPageDelete(record);
451  break;
452  default:
453  elog(PANIC, "gist_redo: unknown op code %u", info);
454  }
455 
456  MemoryContextSwitchTo(oldCxt);
458 }
static void gistRedoPageUpdateRecord(XLogReaderState *record)
Definition: gistxlog.c:72
static void gistRedoPageReuse(XLogReaderState *record)
Definition: gistxlog.c:382
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
unsigned char uint8
Definition: c.h:356
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:136
#define PANIC
Definition: elog.h:53
static void gistRedoPageDelete(XLogReaderState *record)
Definition: gistxlog.c:348
#define XLOG_GIST_PAGE_SPLIT
Definition: gistxlog.h:25
static void gistRedoPageSplitRecord(XLogReaderState *record)
Definition: gistxlog.c:253
#define XLOG_GIST_DELETE
Definition: gistxlog.h:21
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:242
#define XLOG_GIST_PAGE_REUSE
Definition: gistxlog.h:23
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_GIST_PAGE_DELETE
Definition: gistxlog.h:28
static void gistRedoDeleteRecord(XLogReaderState *record)
Definition: gistxlog.c:174
#define elog(elevel,...)
Definition: elog.h:226
static MemoryContext opCtx
Definition: gistxlog.c:28
#define XLOG_GIST_PAGE_UPDATE
Definition: gistxlog.h:20

◆ gist_xlog_cleanup()

void gist_xlog_cleanup ( void  )

Definition at line 467 of file gistxlog.c.

References MemoryContextDelete().

468 {
470 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:211
static MemoryContext opCtx
Definition: gistxlog.c:28

◆ gist_xlog_startup()

void gist_xlog_startup ( void  )

Definition at line 461 of file gistxlog.c.

References createTempGistContext().

462 {
464 }
MemoryContext createTempGistContext(void)
Definition: gist.c:114
static MemoryContext opCtx
Definition: gistxlog.c:28