Line data Source code
1 : /*-------------------------------------------------------------------------
2 : *
3 : * spgdesc.c
4 : * rmgr descriptor routines for access/spgist/spgxlog.c
5 : *
6 : * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
7 : * Portions Copyright (c) 1994, Regents of the University of California
8 : *
9 : *
10 : * IDENTIFICATION
11 : * src/backend/access/rmgrdesc/spgdesc.c
12 : *
13 : *-------------------------------------------------------------------------
14 : */
15 : #include "postgres.h"
16 :
17 : #include "access/spgxlog.h"
18 :
19 : void
20 0 : spg_desc(StringInfo buf, XLogReaderState *record)
21 : {
22 0 : char *rec = XLogRecGetData(record);
23 0 : uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
24 :
25 0 : switch (info)
26 : {
27 : case XLOG_SPGIST_CREATE_INDEX:
28 0 : break;
29 : case XLOG_SPGIST_ADD_LEAF:
30 : {
31 0 : spgxlogAddLeaf *xlrec = (spgxlogAddLeaf *) rec;
32 :
33 0 : appendStringInfoString(buf, "add leaf to page");
34 0 : appendStringInfo(buf, "; off %u; headoff %u; parentoff %u",
35 0 : xlrec->offnumLeaf, xlrec->offnumHeadLeaf,
36 0 : xlrec->offnumParent);
37 0 : if (xlrec->newPage)
38 0 : appendStringInfoString(buf, " (newpage)");
39 0 : if (xlrec->storesNulls)
40 0 : appendStringInfoString(buf, " (nulls)");
41 : }
42 0 : break;
43 : case XLOG_SPGIST_MOVE_LEAFS:
44 0 : appendStringInfo(buf, "%u leafs",
45 0 : ((spgxlogMoveLeafs *) rec)->nMoves);
46 0 : break;
47 : case XLOG_SPGIST_ADD_NODE:
48 0 : appendStringInfo(buf, "off %u",
49 0 : ((spgxlogAddNode *) rec)->offnum);
50 0 : break;
51 : case XLOG_SPGIST_SPLIT_TUPLE:
52 0 : appendStringInfo(buf, "prefix off: %u, postfix off: %u (same %d, new %d)",
53 0 : ((spgxlogSplitTuple *) rec)->offnumPrefix,
54 0 : ((spgxlogSplitTuple *) rec)->offnumPostfix,
55 0 : ((spgxlogSplitTuple *) rec)->postfixBlkSame,
56 0 : ((spgxlogSplitTuple *) rec)->newPage
57 : );
58 0 : break;
59 : case XLOG_SPGIST_PICKSPLIT:
60 : {
61 0 : spgxlogPickSplit *xlrec = (spgxlogPickSplit *) rec;
62 :
63 0 : appendStringInfo(buf, "ndel %u; nins %u",
64 0 : xlrec->nDelete, xlrec->nInsert);
65 0 : if (xlrec->innerIsParent)
66 0 : appendStringInfoString(buf, " (innerIsParent)");
67 0 : if (xlrec->isRootSplit)
68 0 : appendStringInfoString(buf, " (isRootSplit)");
69 : }
70 0 : break;
71 : case XLOG_SPGIST_VACUUM_LEAF:
72 : /* no further information */
73 0 : break;
74 : case XLOG_SPGIST_VACUUM_ROOT:
75 : /* no further information */
76 0 : break;
77 : case XLOG_SPGIST_VACUUM_REDIRECT:
78 0 : appendStringInfo(buf, "newest XID %u",
79 : ((spgxlogVacuumRedirect *) rec)->newestRedirectXid);
80 0 : break;
81 : }
82 0 : }
83 :
84 : const char *
85 0 : spg_identify(uint8 info)
86 : {
87 0 : const char *id = NULL;
88 :
89 0 : switch (info & ~XLR_INFO_MASK)
90 : {
91 : case XLOG_SPGIST_CREATE_INDEX:
92 0 : id = "CREATE_INDEX";
93 0 : break;
94 : case XLOG_SPGIST_ADD_LEAF:
95 0 : id = "ADD_LEAF";
96 0 : break;
97 : case XLOG_SPGIST_MOVE_LEAFS:
98 0 : id = "MOVE_LEAFS";
99 0 : break;
100 : case XLOG_SPGIST_ADD_NODE:
101 0 : id = "ADD_NODE";
102 0 : break;
103 : case XLOG_SPGIST_SPLIT_TUPLE:
104 0 : id = "SPLIT_TUPLE";
105 0 : break;
106 : case XLOG_SPGIST_PICKSPLIT:
107 0 : id = "PICKSPLIT";
108 0 : break;
109 : case XLOG_SPGIST_VACUUM_LEAF:
110 0 : id = "VACUUM_LEAF";
111 0 : break;
112 : case XLOG_SPGIST_VACUUM_ROOT:
113 0 : id = "VACUUM_ROOT";
114 0 : break;
115 : case XLOG_SPGIST_VACUUM_REDIRECT:
116 0 : id = "VACUUM_REDIRECT";
117 0 : break;
118 : }
119 :
120 0 : return id;
121 : }
|