Standardize rmgrdesc recovery conflict XID output.
[pgsql.git] / src / backend / access / rmgrdesc / gistdesc.c
blob97f3520abbcd9555fd3d73a1e3bbf3054490b7a7
1 /*-------------------------------------------------------------------------
3 * gistdesc.c
4 * rmgr descriptor routines for access/gist/gistxlog.c
6 * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
10 * IDENTIFICATION
11 * src/backend/access/rmgrdesc/gistdesc.c
13 *-------------------------------------------------------------------------
15 #include "postgres.h"
17 #include "access/gistxlog.h"
18 #include "lib/stringinfo.h"
19 #include "storage/relfilelocator.h"
21 static void
22 out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
26 static void
27 out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
29 appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%u",
30 xlrec->locator.spcOid, xlrec->locator.dbOid,
31 xlrec->locator.relNumber, xlrec->block,
32 EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
33 XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
36 static void
37 out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
39 appendStringInfo(buf, "delete: snapshotConflictHorizon %u, nitems: %u",
40 xlrec->snapshotConflictHorizon, xlrec->ntodelete);
43 static void
44 out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
46 appendStringInfo(buf, "page_split: splits to %d pages",
47 xlrec->npage);
50 static void
51 out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
53 appendStringInfo(buf, "deleteXid %u:%u; downlink %u",
54 EpochFromFullTransactionId(xlrec->deleteXid),
55 XidFromFullTransactionId(xlrec->deleteXid),
56 xlrec->downlinkOffset);
59 void
60 gist_desc(StringInfo buf, XLogReaderState *record)
62 char *rec = XLogRecGetData(record);
63 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
65 switch (info)
67 case XLOG_GIST_PAGE_UPDATE:
68 out_gistxlogPageUpdate(buf, (gistxlogPageUpdate *) rec);
69 break;
70 case XLOG_GIST_PAGE_REUSE:
71 out_gistxlogPageReuse(buf, (gistxlogPageReuse *) rec);
72 break;
73 case XLOG_GIST_DELETE:
74 out_gistxlogDelete(buf, (gistxlogDelete *) rec);
75 break;
76 case XLOG_GIST_PAGE_SPLIT:
77 out_gistxlogPageSplit(buf, (gistxlogPageSplit *) rec);
78 break;
79 case XLOG_GIST_PAGE_DELETE:
80 out_gistxlogPageDelete(buf, (gistxlogPageDelete *) rec);
81 break;
82 case XLOG_GIST_ASSIGN_LSN:
83 /* No details to write out */
84 break;
88 const char *
89 gist_identify(uint8 info)
91 const char *id = NULL;
93 switch (info & ~XLR_INFO_MASK)
95 case XLOG_GIST_PAGE_UPDATE:
96 id = "PAGE_UPDATE";
97 break;
98 case XLOG_GIST_DELETE:
99 id = "DELETE";
100 break;
101 case XLOG_GIST_PAGE_REUSE:
102 id = "PAGE_REUSE";
103 break;
104 case XLOG_GIST_PAGE_SPLIT:
105 id = "PAGE_SPLIT";
106 break;
107 case XLOG_GIST_PAGE_DELETE:
108 id = "PAGE_DELETE";
109 break;
110 case XLOG_GIST_ASSIGN_LSN:
111 id = "ASSIGN_LSN";
112 break;
115 return id;