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  gistxlogPageSplit
 

Macros

#define XLOG_GIST_PAGE_UPDATE   0x00
 
#define XLOG_GIST_PAGE_SPLIT   0x30
 
#define XLOG_GIST_CREATE_INDEX   0x50
 

Typedefs

typedef struct gistxlogPageUpdate gistxlogPageUpdate
 
typedef struct gistxlogPageSplit gistxlogPageSplit
 

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

◆ XLOG_GIST_CREATE_INDEX

#define XLOG_GIST_CREATE_INDEX   0x50

Definition at line 24 of file gistxlog.h.

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

◆ XLOG_GIST_PAGE_SPLIT

#define XLOG_GIST_PAGE_SPLIT   0x30

Definition at line 22 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

◆ gistxlogPageSplit

◆ gistxlogPageUpdate

Function Documentation

◆ gist_desc()

void gist_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 34 of file gistdesc.c.

References out_gistxlogPageSplit(), out_gistxlogPageUpdate(), XLOG_GIST_CREATE_INDEX, XLOG_GIST_PAGE_SPLIT, XLOG_GIST_PAGE_UPDATE, XLogRecGetData, XLogRecGetInfo, and XLR_INFO_MASK.

35 {
36  char *rec = XLogRecGetData(record);
37  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
38 
39  switch (info)
40  {
43  break;
46  break;
48  break;
49  }
50 }
static void out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
Definition: gistdesc.c:27
unsigned char uint8
Definition: c.h:294
#define XLOG_GIST_CREATE_INDEX
Definition: gistxlog.h:24
#define XLogRecGetData(decoder)
Definition: xlogreader.h:226
#define XLOG_GIST_PAGE_SPLIT
Definition: gistxlog.h:22
static void out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
Definition: gistdesc.c:22
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:222
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_GIST_PAGE_UPDATE
Definition: gistxlog.h:20

◆ gist_identify()

const char* gist_identify ( uint8  info)

Definition at line 53 of file gistdesc.c.

References XLOG_GIST_CREATE_INDEX, XLOG_GIST_PAGE_SPLIT, XLOG_GIST_PAGE_UPDATE, and XLR_INFO_MASK.

54 {
55  const char *id = NULL;
56 
57  switch (info & ~XLR_INFO_MASK)
58  {
60  id = "PAGE_UPDATE";
61  break;
63  id = "PAGE_SPLIT";
64  break;
66  id = "CREATE_INDEX";
67  break;
68  }
69 
70  return id;
71 }
#define XLOG_GIST_CREATE_INDEX
Definition: gistxlog.h:24
#define XLOG_GIST_PAGE_SPLIT
Definition: gistxlog.h:22
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_GIST_PAGE_UPDATE
Definition: gistxlog.h:20

◆ gist_mask()

void gist_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 351 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().

352 {
353  Page page = (Page) pagedata;
354 
356 
357  mask_page_hint_bits(page);
358  mask_unused_space(page);
359 
360  /*
361  * NSN is nothing but a special purpose LSN. Hence, mask it for the same
362  * reason as mask_page_lsn_and_checksum.
363  */
364  GistPageSetNSN(page, (uint64) MASK_MARKER);
365 
366  /*
367  * We update F_FOLLOW_RIGHT flag on the left child after writing WAL
368  * record. Hence, mask this flag. See gistplacetopage() for details.
369  */
370  GistMarkFollowRight(page);
371 
372  if (GistPageIsLeaf(page))
373  {
374  /*
375  * In gist leaf pages, it is possible to modify the LP_FLAGS without
376  * emitting any WAL record. Hence, mask the line pointer flags. See
377  * gistkillitems() for details.
378  */
379  mask_lp_flags(page);
380  }
381 
382  /*
383  * During gist redo, we never mark a page as garbage. Hence, mask it to
384  * ignore any differences.
385  */
387 }
#define GistClearPageHasGarbage(page)
Definition: gist.h:145
void mask_page_hint_bits(Page page)
Definition: bufmask.c:46
#define GistPageSetNSN(page, val)
Definition: gist.h:152
void mask_unused_space(Page page)
Definition: bufmask.c:71
#define MASK_MARKER
Definition: bufmask.h:24
#define GistPageIsLeaf(page)
Definition: gist.h:132
void mask_page_lsn_and_checksum(Page page)
Definition: bufmask.c:31
#define GistMarkFollowRight(page)
Definition: gist.h:148
void mask_lp_flags(Page page)
Definition: bufmask.c:95
Pointer Page
Definition: bufpage.h:74

◆ gist_redo()

void gist_redo ( XLogReaderState record)

Definition at line 304 of file gistxlog.c.

References elog, gistRedoCreateIndex(), gistRedoPageSplitRecord(), gistRedoPageUpdateRecord(), MemoryContextReset(), MemoryContextSwitchTo(), PANIC, XLOG_GIST_CREATE_INDEX, XLOG_GIST_PAGE_SPLIT, XLOG_GIST_PAGE_UPDATE, XLogRecGetInfo, and XLR_INFO_MASK.

305 {
306  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
307  MemoryContext oldCxt;
308 
309  /*
310  * GiST indexes do not require any conflict processing. NB: If we ever
311  * implement a similar optimization we have in b-tree, and remove killed
312  * tuples outside VACUUM, we'll need to handle that here.
313  */
314 
315  oldCxt = MemoryContextSwitchTo(opCtx);
316  switch (info)
317  {
319  gistRedoPageUpdateRecord(record);
320  break;
322  gistRedoPageSplitRecord(record);
323  break;
325  gistRedoCreateIndex(record);
326  break;
327  default:
328  elog(PANIC, "gist_redo: unknown op code %u", info);
329  }
330 
331  MemoryContextSwitchTo(oldCxt);
333 }
static void gistRedoPageUpdateRecord(XLogReaderState *record)
Definition: gistxlog.c:67
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
unsigned char uint8
Definition: c.h:294
#define XLOG_GIST_CREATE_INDEX
Definition: gistxlog.h:24
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:135
#define PANIC
Definition: elog.h:53
#define XLOG_GIST_PAGE_SPLIT
Definition: gistxlog.h:22
static void gistRedoPageSplitRecord(XLogReaderState *record)
Definition: gistxlog.c:191
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:222
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
static MemoryContext opCtx
Definition: gistxlog.c:23
#define elog
Definition: elog.h:219
#define XLOG_GIST_PAGE_UPDATE
Definition: gistxlog.h:20
static void gistRedoCreateIndex(XLogReaderState *record)
Definition: gistxlog.c:285

◆ gist_xlog_cleanup()

void gist_xlog_cleanup ( void  )

Definition at line 342 of file gistxlog.c.

References MemoryContextDelete().

343 {
345 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:200
static MemoryContext opCtx
Definition: gistxlog.c:23

◆ gist_xlog_startup()

void gist_xlog_startup ( void  )

Definition at line 336 of file gistxlog.c.

References createTempGistContext().

337 {
339 }
MemoryContext createTempGistContext(void)
Definition: gist.c:110
static MemoryContext opCtx
Definition: gistxlog.c:23