1/*-------------------------------------------------------------------------
2 *
3 * gistdesc.c
4 * rmgr descriptor routines for access/gist/gistxlog.c
5 *
6 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 *
10 * IDENTIFICATION
11 * src/backend/access/rmgrdesc/gistdesc.c
12 *
13 *-------------------------------------------------------------------------
14 */
15#include "postgres.h"
16
17#include "access/gistxlog.h"
18#include "lib/stringinfo.h"
19#include "storage/relfilenode.h"
20
21static void
22out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
23{
24}
25
26static void
27out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
28{
29 appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%u",
30 xlrec->node.spcNode, xlrec->node.dbNode,
31 xlrec->node.relNode, xlrec->block,
32 EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
33 XidFromFullTransactionId(xlrec->latestRemovedFullXid));
34}
35
36static void
37out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
38{
39 appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
40 xlrec->latestRemovedXid, xlrec->ntodelete);
41
42}
43
44static void
45out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
46{
47 appendStringInfo(buf, "page_split: splits to %d pages",
48 xlrec->npage);
49}
50
51static void
52out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
53{
54 appendStringInfo(buf, "deleteXid %u:%u; downlink %u",
55 EpochFromFullTransactionId(xlrec->deleteXid),
56 XidFromFullTransactionId(xlrec->deleteXid),
57 xlrec->downlinkOffset);
58}
59
60void
61gist_desc(StringInfo buf, XLogReaderState *record)
62{
63 char *rec = XLogRecGetData(record);
64 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
65
66 switch (info)
67 {
68 case XLOG_GIST_PAGE_UPDATE:
69 out_gistxlogPageUpdate(buf, (gistxlogPageUpdate *) rec);
70 break;
71 case XLOG_GIST_PAGE_REUSE:
72 out_gistxlogPageReuse(buf, (gistxlogPageReuse *) rec);
73 break;
74 case XLOG_GIST_DELETE:
75 out_gistxlogDelete(buf, (gistxlogDelete *) rec);
76 break;
77 case XLOG_GIST_PAGE_SPLIT:
78 out_gistxlogPageSplit(buf, (gistxlogPageSplit *) rec);
79 break;
80 case XLOG_GIST_PAGE_DELETE:
81 out_gistxlogPageDelete(buf, (gistxlogPageDelete *) rec);
82 break;
83 }
84}
85
86const char *
87gist_identify(uint8 info)
88{
89 const char *id = NULL;
90
91 switch (info & ~XLR_INFO_MASK)
92 {
93 case XLOG_GIST_PAGE_UPDATE:
94 id = "PAGE_UPDATE";
95 break;
96 case XLOG_GIST_DELETE:
97 id = "DELETE";
98 break;
99 case XLOG_GIST_PAGE_REUSE:
100 id = "PAGE_REUSE";
101 break;
102 case XLOG_GIST_PAGE_SPLIT:
103 id = "PAGE_SPLIT";
104 break;
105 case XLOG_GIST_PAGE_DELETE:
106 id = "PAGE_DELETE";
107 break;
108 }
109
110 return id;
111}
112