summaryrefslogtreecommitdiffstats
path: root/src/backend/access/rmgrdesc/spgdesc.c
blob: 87f62f0fb4b383c3e75142deb7d2bb2259e22e0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*-------------------------------------------------------------------------
 *
 * spgdesc.c
 *	  rmgr descriptor routines for access/spgist/spgxlog.c
 *
 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 *
 * IDENTIFICATION
 *	  src/backend/access/rmgrdesc/spgdesc.c
 *
 *-------------------------------------------------------------------------
 */
#include "postgres.h"

#include "access/spgxlog.h"

void
spg_desc(StringInfo buf, XLogReaderState *record)
{
	char	   *rec = XLogRecGetData(record);
	uint8		info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;

	switch (info)
	{
		case XLOG_SPGIST_ADD_LEAF:
			{
				spgxlogAddLeaf *xlrec = (spgxlogAddLeaf *) rec;

				appendStringInfo(buf, "off: %u, headoff: %u, parentoff: %u, nodeI: %u",
								 xlrec->offnumLeaf, xlrec->offnumHeadLeaf,
								 xlrec->offnumParent, xlrec->nodeI);
				if (xlrec->newPage)
					appendStringInfoString(buf, " (newpage)");
				if (xlrec->storesNulls)
					appendStringInfoString(buf, " (nulls)");
			}
			break;
		case XLOG_SPGIST_MOVE_LEAFS:
			{
				spgxlogMoveLeafs *xlrec = (spgxlogMoveLeafs *) rec;

				appendStringInfo(buf, "nmoves: %u, parentoff: %u, nodeI: %u",
								 xlrec->nMoves,
								 xlrec->offnumParent, xlrec->nodeI);
				if (xlrec->newPage)
					appendStringInfoString(buf, " (newpage)");
				if (xlrec->replaceDead)
					appendStringInfoString(buf, " (replacedead)");
				if (xlrec->storesNulls)
					appendStringInfoString(buf, " (nulls)");
			}
			break;
		case XLOG_SPGIST_ADD_NODE:
			{
				spgxlogAddNode *xlrec = (spgxlogAddNode *) rec;

				appendStringInfo(buf, "off: %u, newoff: %u, parentBlk: %d, "
								 "parentoff: %u, nodeI: %u",
								 xlrec->offnum,
								 xlrec->offnumNew,
								 xlrec->parentBlk,
								 xlrec->offnumParent,
								 xlrec->nodeI);
				if (xlrec->newPage)
					appendStringInfoString(buf, " (newpage)");
			}
			break;
		case XLOG_SPGIST_SPLIT_TUPLE:
			{
				spgxlogSplitTuple *xlrec = (spgxlogSplitTuple *) rec;

				appendStringInfo(buf, "prefixoff: %u, postfixoff: %u",
								 xlrec->offnumPrefix,
								 xlrec->offnumPostfix);
				if (xlrec->newPage)
					appendStringInfoString(buf, " (newpage)");
				if (xlrec->postfixBlkSame)
					appendStringInfoString(buf, " (same)");
			}
			break;
		case XLOG_SPGIST_PICKSPLIT:
			{
				spgxlogPickSplit *xlrec = (spgxlogPickSplit *) rec;

				appendStringInfo(buf, "ndelete: %u, ninsert: %u, inneroff: %u, "
								 "parentoff: %u, nodeI: %u",
								 xlrec->nDelete, xlrec->nInsert,
								 xlrec->offnumInner,
								 xlrec->offnumParent, xlrec->nodeI);
				if (xlrec->innerIsParent)
					appendStringInfoString(buf, " (innerIsParent)");
				if (xlrec->storesNulls)
					appendStringInfoString(buf, " (nulls)");
				if (xlrec->isRootSplit)
					appendStringInfoString(buf, " (isRootSplit)");
			}
			break;
		case XLOG_SPGIST_VACUUM_LEAF:
			{
				spgxlogVacuumLeaf *xlrec = (spgxlogVacuumLeaf *) rec;

				appendStringInfo(buf, "ndead: %u, nplaceholder: %u, nmove: %u, nchain: %u",
								 xlrec->nDead, xlrec->nPlaceholder,
								 xlrec->nMove, xlrec->nChain);
			}
			break;
		case XLOG_SPGIST_VACUUM_ROOT:
			{
				spgxlogVacuumRoot *xlrec = (spgxlogVacuumRoot *) rec;

				appendStringInfo(buf, "ndelete: %u",
								 xlrec->nDelete);
			}
			break;
		case XLOG_SPGIST_VACUUM_REDIRECT:
			{
				spgxlogVacuumRedirect *xlrec = (spgxlogVacuumRedirect *) rec;

				appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, snapshotConflictHorizon: %u",
								 xlrec->nToPlaceholder,
								 xlrec->firstPlaceholder,
								 xlrec->snapshotConflictHorizon);
			}
			break;
	}
}

const char *
spg_identify(uint8 info)
{
	const char *id = NULL;

	switch (info & ~XLR_INFO_MASK)
	{
		case XLOG_SPGIST_ADD_LEAF:
			id = "ADD_LEAF";
			break;
		case XLOG_SPGIST_MOVE_LEAFS:
			id = "MOVE_LEAFS";
			break;
		case XLOG_SPGIST_ADD_NODE:
			id = "ADD_NODE";
			break;
		case XLOG_SPGIST_SPLIT_TUPLE:
			id = "SPLIT_TUPLE";
			break;
		case XLOG_SPGIST_PICKSPLIT:
			id = "PICKSPLIT";
			break;
		case XLOG_SPGIST_VACUUM_LEAF:
			id = "VACUUM_LEAF";
			break;
		case XLOG_SPGIST_VACUUM_ROOT:
			id = "VACUUM_ROOT";
			break;
		case XLOG_SPGIST_VACUUM_REDIRECT:
			id = "VACUUM_REDIRECT";
			break;
	}

	return id;
}