PostgreSQL Source Code  git master
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-2024, 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  int64 pageno;
59 
60  memcpy(&pageno, rec, sizeof(pageno));
61  appendStringInfo(buf, "%lld", (long long) 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:490
int i
Definition: isn.c:72
#define XLOG_MULTIXACT_ZERO_MEM_PAGE
Definition: multixact.h:69
#define XLOG_MULTIXACT_ZERO_OFF_PAGE
Definition: multixact.h:68
@ MultiXactStatusForShare
Definition: multixact.h:40
@ MultiXactStatusForNoKeyUpdate
Definition: multixact.h:41
@ MultiXactStatusNoKeyUpdate
Definition: multixact.h:44
@ MultiXactStatusUpdate
Definition: multixact.h:46
@ MultiXactStatusForUpdate
Definition: multixact.h:42
@ MultiXactStatusForKeyShare
Definition: multixact.h:39
#define XLOG_MULTIXACT_TRUNCATE_ID
Definition: multixact.h:71
#define XLOG_MULTIXACT_CREATE_ID
Definition: multixact.h:70
const char * multixact_identify(uint8 info)
Definition: mxactdesc.c:84
static void out_member(StringInfo buf, MultiXactMember *member)
Definition: mxactdesc.c:20
void multixact_desc(StringInfo buf, XLogReaderState *record)
Definition: mxactdesc.c:50
static char * buf
Definition: pg_test_fsync.c:72
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:94
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:179
TransactionId xid
Definition: multixact.h:58
MultiXactStatus status
Definition: multixact.h:59
MultiXactId mid
Definition: multixact.h:75
MultiXactMember members[FLEXIBLE_ARRAY_MEMBER]
Definition: multixact.h:78
MultiXactOffset moff
Definition: multixact.h:76
MultiXactId endTruncOff
Definition: multixact.h:89
MultiXactOffset startTruncMemb
Definition: multixact.h:92
MultiXactOffset endTruncMemb
Definition: multixact.h:93
MultiXactId startTruncOff
Definition: multixact.h:88
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:410
#define XLogRecGetData(decoder)
Definition: xlogreader.h:415
#define XLR_INFO_MASK
Definition: xlogrecord.h:62