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