]> granicus.if.org Git - postgresql/blob - src/backend/access/rmgrdesc/mxactdesc.c
Use appendStringInfoString instead of appendStringInfo where possible.
[postgresql] / src / backend / access / rmgrdesc / mxactdesc.c
1 /*-------------------------------------------------------------------------
2  *
3  * mxactdesc.c
4  *        rmgr descriptor routines for access/transam/multixact.c
5  *
6  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  *        src/backend/access/rmgrdesc/mxactdesc.c
12  *
13  *-------------------------------------------------------------------------
14  */
15 #include "postgres.h"
16
17 #include "access/multixact.h"
18
19 static void
20 out_member(StringInfo buf, MultiXactMember *member)
21 {
22         appendStringInfo(buf, "%u ", member->xid);
23         switch (member->status)
24         {
25                 case MultiXactStatusForKeyShare:
26                         appendStringInfoString(buf, "(keysh) ");
27                         break;
28                 case MultiXactStatusForShare:
29                         appendStringInfoString(buf, "(sh) ");
30                         break;
31                 case MultiXactStatusForNoKeyUpdate:
32                         appendStringInfoString(buf, "(fornokeyupd) ");
33                         break;
34                 case MultiXactStatusForUpdate:
35                         appendStringInfoString(buf, "(forupd) ");
36                         break;
37                 case MultiXactStatusNoKeyUpdate:
38                         appendStringInfoString(buf, "(nokeyupd) ");
39                         break;
40                 case MultiXactStatusUpdate:
41                         appendStringInfoString(buf, "(upd) ");
42                         break;
43                 default:
44                         appendStringInfoString(buf, "(unk) ");
45                         break;
46         }
47 }
48
49 void
50 multixact_desc(StringInfo buf, uint8 xl_info, char *rec)
51 {
52         uint8           info = xl_info & ~XLR_INFO_MASK;
53
54         if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
55         {
56                 int                     pageno;
57
58                 memcpy(&pageno, rec, sizeof(int));
59                 appendStringInfo(buf, "zero offsets page: %d", pageno);
60         }
61         else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
62         {
63                 int                     pageno;
64
65                 memcpy(&pageno, rec, sizeof(int));
66                 appendStringInfo(buf, "zero members page: %d", pageno);
67         }
68         else if (info == XLOG_MULTIXACT_CREATE_ID)
69         {
70                 xl_multixact_create *xlrec = (xl_multixact_create *) rec;
71                 int                     i;
72
73                 appendStringInfo(buf, "create mxid %u offset %u nmembers %d: ", xlrec->mid,
74                                                  xlrec->moff, xlrec->nmembers);
75                 for (i = 0; i < xlrec->nmembers; i++)
76                         out_member(buf, &xlrec->members[i]);
77         }
78         else
79                 appendStringInfoString(buf, "UNKNOWN");
80 }