PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
mxactdesc.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * mxactdesc.c
4  * rmgr descriptor routines for access/transam/multixact.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/mxactdesc.c
12  *
13  *-------------------------------------------------------------------------
14  */
15 #include "postgres.h"
16 
17 #include "access/multixact.h"
18 
19 static void
21 {
22  appendStringInfo(buf, "%u ", member->xid);
23  switch (member->status)
24  {
26  appendStringInfoString(buf, "(keysh) ");
27  break;
29  appendStringInfoString(buf, "(sh) ");
30  break;
32  appendStringInfoString(buf, "(fornokeyupd) ");
33  break;
35  appendStringInfoString(buf, "(forupd) ");
36  break;
38  appendStringInfoString(buf, "(nokeyupd) ");
39  break;
41  appendStringInfoString(buf, "(upd) ");
42  break;
43  default:
44  appendStringInfoString(buf, "(unk) ");
45  break;
46  }
47 }
48 
49 void
51 {
52  char *rec = XLogRecGetData(record);
53  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
54 
55  if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
57  {
58  int pageno;
59 
60  memcpy(&pageno, rec, sizeof(int));
61  appendStringInfo(buf, "%d", pageno);
62  }
63  else if (info == XLOG_MULTIXACT_CREATE_ID)
64  {
66  int i;
67 
68  appendStringInfo(buf, "%u offset %u nmembers %d: ", xlrec->mid,
69  xlrec->moff, xlrec->nmembers);
70  for (i = 0; i < xlrec->nmembers; i++)
71  out_member(buf, &xlrec->members[i]);
72  }
73  else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
74  {
76 
77  appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
78  xlrec->startTruncOff, xlrec->endTruncOff,
79  xlrec->startTruncMemb, xlrec->endTruncMemb);
80  }
81 }
82 
83 const char *
85 {
86  const char *id = NULL;
87 
88  switch (info & ~XLR_INFO_MASK)
89  {
91  id = "ZERO_OFF_PAGE";
92  break;
94  id = "ZERO_MEM_PAGE";
95  break;
97  id = "CREATE_ID";
98  break;
100  id = "TRUNCATE_ID";
101  break;
102  }
103 
104  return id;
105 }
unsigned char uint8
Definition: c.h:266
#define XLOG_MULTIXACT_ZERO_MEM_PAGE
Definition: multixact.h:72
MultiXactMember members[FLEXIBLE_ARRAY_MEMBER]
Definition: multixact.h:81
#define XLogRecGetData(decoder)
Definition: xlogreader.h:220
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:78
#define XLOG_MULTIXACT_CREATE_ID
Definition: multixact.h:73
TransactionId xid
Definition: multixact.h:61
MultiXactOffset moff
Definition: multixact.h:79
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:157
static char * buf
Definition: pg_test_fsync.c:66
MultiXactStatus status
Definition: multixact.h:62
static void out_member(StringInfo buf, MultiXactMember *member)
Definition: mxactdesc.c:20
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:216
MultiXactOffset endTruncMemb
Definition: multixact.h:96
const char * multixact_identify(uint8 info)
Definition: mxactdesc.c:84
#define XLOG_MULTIXACT_ZERO_OFF_PAGE
Definition: multixact.h:71
MultiXactOffset startTruncMemb
Definition: multixact.h:95
MultiXactId mid
Definition: multixact.h:78
#define NULL
Definition: c.h:229
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_MULTIXACT_TRUNCATE_ID
Definition: multixact.h:74
MultiXactId startTruncOff
Definition: multixact.h:91
void multixact_desc(StringInfo buf, XLogReaderState *record)
Definition: mxactdesc.c:50
int i
MultiXactId endTruncOff
Definition: multixact.h:92